|
| 1 | +<UserControl x:Class="MaterialDesignColors.WpfExample.Lists" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 6 | + xmlns:local="clr-namespace:MaterialDesignColors.WpfExample" |
| 7 | + xmlns:domain="clr-namespace:MaterialDesignColors.WpfExample.Domain" |
| 8 | + mc:Ignorable="d" |
| 9 | + d:DesignHeight="300" d:DesignWidth="300"> |
| 10 | + <UserControl.Resources> |
| 11 | + <ResourceDictionary> |
| 12 | + <ResourceDictionary.MergedDictionaries> |
| 13 | + <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToggleButton.xaml" /> |
| 14 | + </ResourceDictionary.MergedDictionaries> |
| 15 | + </ResourceDictionary> |
| 16 | + </UserControl.Resources> |
| 17 | + <Grid Margin="8"> |
| 18 | + <Grid.ColumnDefinitions> |
| 19 | + <ColumnDefinition Width="1*" /> |
| 20 | + <ColumnDefinition Width="1*" /> |
| 21 | + <ColumnDefinition Width="1*" /> |
| 22 | + </Grid.ColumnDefinitions> |
| 23 | + <ListBox Grid.Column="0"> |
| 24 | + <TextBlock>Plain</TextBlock> |
| 25 | + <TextBlock>Old</TextBlock> |
| 26 | + <TextBlock>ListBox</TextBlock> |
| 27 | + <TextBlock>Full of junk</TextBlock> |
| 28 | + </ListBox> |
| 29 | + <!-- piece together your own items control to create some nice stuff that will make everyone think you are cool. and rightly so, because you are cool. you might even be a hipster for all I know --> |
| 30 | + <ItemsControl Grid.Column="1" ItemsSource="{Binding Items1}" |
| 31 | + Grid.IsSharedSizeScope="True" |
| 32 | + Margin="12 0 12 0"> |
| 33 | + <ItemsControl.ItemTemplate> |
| 34 | + <DataTemplate DataType="{x:Type domain:SelectableViewModel}"> |
| 35 | + <Border x:Name="Border" Padding="8"> |
| 36 | + <Grid> |
| 37 | + <Grid.ColumnDefinitions> |
| 38 | + <ColumnDefinition SharedSizeGroup="Checkerz" /> |
| 39 | + <ColumnDefinition /> |
| 40 | + </Grid.ColumnDefinitions> |
| 41 | + <CheckBox VerticalAlignment="Center" IsChecked="{Binding IsSelected}"/> |
| 42 | + <StackPanel Margin="8 0 0 0" Grid.Column="1"> |
| 43 | + <TextBlock FontWeight="Bold" Text="{Binding Name}" /> |
| 44 | + <TextBlock Text="{Binding Description}" /> |
| 45 | + </StackPanel> |
| 46 | + </Grid> |
| 47 | + </Border> |
| 48 | + <DataTemplate.Triggers> |
| 49 | + <DataTrigger Binding="{Binding IsSelected}" Value="True"> |
| 50 | + <Setter TargetName="Border" Property="Background" Value="{DynamicResource MaterialDesignSelection}" /> |
| 51 | + </DataTrigger> |
| 52 | + </DataTemplate.Triggers> |
| 53 | + </DataTemplate> |
| 54 | + </ItemsControl.ItemTemplate> |
| 55 | + </ItemsControl> |
| 56 | + <!-- and here's another --> |
| 57 | + <ItemsControl Grid.Column="2" ItemsSource="{Binding Items2}" |
| 58 | + Grid.IsSharedSizeScope="True"> |
| 59 | + <ItemsControl.ItemTemplate> |
| 60 | + <DataTemplate DataType="{x:Type domain:SelectableViewModel}"> |
| 61 | + <Border x:Name="Border" Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}"> |
| 62 | + <Grid> |
| 63 | + <Grid.ColumnDefinitions> |
| 64 | + <ColumnDefinition SharedSizeGroup="Checkerz" /> |
| 65 | + <ColumnDefinition /> |
| 66 | + </Grid.ColumnDefinitions> |
| 67 | + <ToggleButton VerticalAlignment="Center" IsChecked="{Binding IsSelected}" |
| 68 | + Style="{StaticResource MaterialDesignActionLightToggleButton}" |
| 69 | + Content="{Binding Code}" /> |
| 70 | + <StackPanel Margin="8 0 0 0" Grid.Column="1"> |
| 71 | + <TextBlock FontWeight="Bold" Text="{Binding Name}" /> |
| 72 | + <TextBlock Text="{Binding Description}" /> |
| 73 | + </StackPanel> |
| 74 | + </Grid> |
| 75 | + </Border> |
| 76 | + <DataTemplate.Triggers> |
| 77 | + <DataTrigger Binding="{Binding IsSelected}" Value="True"> |
| 78 | + <Setter TargetName="Border" Property="Background" Value="{DynamicResource MaterialDesignSelection}" /> |
| 79 | + </DataTrigger> |
| 80 | + </DataTemplate.Triggers> |
| 81 | + </DataTemplate> |
| 82 | + </ItemsControl.ItemTemplate> |
| 83 | + </ItemsControl> |
| 84 | + </Grid> |
| 85 | +</UserControl> |
0 commit comments