Skip to content

Commit 4189fec

Browse files
committed
Successfully injected XamlDisplayerXaml into Lists.xaml
1 parent 10f1162 commit 4189fec

File tree

2 files changed

+65
-83
lines changed

2 files changed

+65
-83
lines changed

MainDemo.Wpf/Lists.xaml

Lines changed: 63 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:domain="clr-namespace:MaterialDesignColors.WpfExample.Domain"
7+
xmlns:codeDisplayer="clr-namespace:CodeDisplayer;assembly=CodeDisplayer"
78
mc:Ignorable="d"
89
d:DesignHeight="300" d:DesignWidth="300">
910
<UserControl.Resources>
@@ -14,91 +15,70 @@
1415
</ResourceDictionary.MergedDictionaries>
1516
</ResourceDictionary>
1617
</UserControl.Resources>
17-
<Grid Margin="8" >
18-
<Grid.RowDefinitions>
19-
<RowDefinition Height="Auto" />
20-
<RowDefinition Height="Auto" />
21-
<RowDefinition Height="Auto" />
22-
<RowDefinition Height="Auto" />
23-
<RowDefinition Height="Auto" />
24-
<RowDefinition Height="Auto" />
25-
</Grid.RowDefinitions>
18+
<codeDisplayer:XamlDisplayerPanel x:Name="XamlDisplayerPanel" Margin="8" >
2619
<TextBlock Style="{StaticResource MaterialDesignTitleTextBlock}">ListBox</TextBlock>
27-
<Grid Grid.Row="1">
28-
<Grid.RowDefinitions>
29-
<RowDefinition/>
30-
<RowDefinition Height="Auto"/>
31-
</Grid.RowDefinitions>
32-
<Grid.ColumnDefinitions>
33-
<ColumnDefinition Width="1*" />
34-
<ColumnDefinition Width="1*" />
35-
<ColumnDefinition Width="1*" />
36-
</Grid.ColumnDefinitions>
37-
<ListBox Grid.Column="0" IsEnabled="{Binding IsChecked, ElementName=EnableListBox}">
38-
<TextBlock>Plain</TextBlock>
39-
<TextBlock>Old</TextBlock>
40-
<TextBlock>ListBox</TextBlock>
41-
<TextBlock>Full of junk</TextBlock>
42-
</ListBox>
43-
<CheckBox Name="EnableListBox" Grid.Row="1" IsChecked="True">Enabled</CheckBox>
44-
<!-- 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 -->
45-
<ItemsControl Grid.Column="1" ItemsSource="{Binding Items1}"
20+
<ListBox IsEnabled="{Binding IsChecked, ElementName=EnableListBox}">
21+
<TextBlock>Plain</TextBlock>
22+
<TextBlock>Old</TextBlock>
23+
<TextBlock>ListBox</TextBlock>
24+
<TextBlock>Full of junk</TextBlock>
25+
</ListBox>
26+
<CheckBox Name="EnableListBox" IsChecked="True">Enabled</CheckBox>
27+
<ItemsControl ItemsSource="{Binding Items1}"
4628
Grid.IsSharedSizeScope="True"
4729
Margin="12 0 12 0">
48-
<ItemsControl.ItemTemplate>
49-
<DataTemplate DataType="{x:Type domain:SelectableViewModel}">
50-
<Border x:Name="Border" Padding="8">
51-
<Grid>
52-
<Grid.ColumnDefinitions>
53-
<ColumnDefinition SharedSizeGroup="Checkerz" />
54-
<ColumnDefinition />
55-
</Grid.ColumnDefinitions>
56-
<CheckBox VerticalAlignment="Center" IsChecked="{Binding IsSelected}"/>
57-
<StackPanel Margin="8 0 0 0" Grid.Column="1">
58-
<TextBlock FontWeight="Bold" Text="{Binding Name}" />
59-
<TextBlock Text="{Binding Description}" />
60-
</StackPanel>
61-
</Grid>
62-
</Border>
63-
<DataTemplate.Triggers>
64-
<DataTrigger Binding="{Binding IsSelected}" Value="True">
65-
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MaterialDesignSelection}" />
66-
</DataTrigger>
67-
</DataTemplate.Triggers>
68-
</DataTemplate>
69-
</ItemsControl.ItemTemplate>
70-
</ItemsControl>
71-
<!-- and here's another -->
72-
<ItemsControl Grid.Column="2" ItemsSource="{Binding Items2}"
30+
<ItemsControl.ItemTemplate>
31+
<DataTemplate DataType="{x:Type domain:SelectableViewModel}">
32+
<Border x:Name="Border" Padding="8">
33+
<Grid>
34+
<Grid.ColumnDefinitions>
35+
<ColumnDefinition SharedSizeGroup="Checkerz" />
36+
<ColumnDefinition />
37+
</Grid.ColumnDefinitions>
38+
<CheckBox VerticalAlignment="Center" IsChecked="{Binding IsSelected}"/>
39+
<StackPanel Margin="8 0 0 0" Grid.Column="1">
40+
<TextBlock FontWeight="Bold" Text="{Binding Name}" />
41+
<TextBlock Text="{Binding Description}" />
42+
</StackPanel>
43+
</Grid>
44+
</Border>
45+
<DataTemplate.Triggers>
46+
<DataTrigger Binding="{Binding IsSelected}" Value="True">
47+
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MaterialDesignSelection}" />
48+
</DataTrigger>
49+
</DataTemplate.Triggers>
50+
</DataTemplate>
51+
</ItemsControl.ItemTemplate>
52+
</ItemsControl>
53+
<ItemsControl ItemsSource="{Binding Items2}"
7354
Grid.IsSharedSizeScope="True">
74-
<ItemsControl.ItemTemplate>
75-
<DataTemplate DataType="{x:Type domain:SelectableViewModel}">
76-
<Border x:Name="Border" Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}">
77-
<Grid>
78-
<Grid.ColumnDefinitions>
79-
<ColumnDefinition SharedSizeGroup="Checkerz" />
80-
<ColumnDefinition />
81-
</Grid.ColumnDefinitions>
82-
<ToggleButton VerticalAlignment="Center" IsChecked="{Binding IsSelected}"
55+
<ItemsControl.ItemTemplate>
56+
<DataTemplate DataType="{x:Type domain:SelectableViewModel}">
57+
<Border x:Name="Border" Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}">
58+
<Grid>
59+
<Grid.ColumnDefinitions>
60+
<ColumnDefinition SharedSizeGroup="Checkerz" />
61+
<ColumnDefinition />
62+
</Grid.ColumnDefinitions>
63+
<ToggleButton VerticalAlignment="Center" IsChecked="{Binding IsSelected}"
8364
Style="{StaticResource MaterialDesignActionLightToggleButton}"
8465
Content="{Binding Code}" />
85-
<StackPanel Margin="8 0 0 0" Grid.Column="1">
86-
<TextBlock FontWeight="Bold" Text="{Binding Name}" />
87-
<TextBlock Text="{Binding Description}" />
88-
</StackPanel>
89-
</Grid>
90-
</Border>
91-
<DataTemplate.Triggers>
92-
<DataTrigger Binding="{Binding IsSelected}" Value="True">
93-
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MaterialDesignSelection}" />
94-
</DataTrigger>
95-
</DataTemplate.Triggers>
96-
</DataTemplate>
97-
</ItemsControl.ItemTemplate>
98-
</ItemsControl>
99-
</Grid>
100-
<TextBlock Style="{StaticResource MaterialDesignTitleTextBlock}" Grid.Row="2" Margin="0 32 0 0">ListView</TextBlock>
101-
<ListView Grid.Row="3">
66+
<StackPanel Margin="8 0 0 0" Grid.Column="1">
67+
<TextBlock FontWeight="Bold" Text="{Binding Name}" />
68+
<TextBlock Text="{Binding Description}" />
69+
</StackPanel>
70+
</Grid>
71+
</Border>
72+
<DataTemplate.Triggers>
73+
<DataTrigger Binding="{Binding IsSelected}" Value="True">
74+
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MaterialDesignSelection}" />
75+
</DataTrigger>
76+
</DataTemplate.Triggers>
77+
</DataTemplate>
78+
</ItemsControl.ItemTemplate>
79+
</ItemsControl>
80+
<TextBlock Style="{StaticResource MaterialDesignTitleTextBlock}" Margin="0 32 0 0">ListView</TextBlock>
81+
<ListView >
10282
<ListViewItem>
10383
Hello
10484
</ListViewItem>
@@ -109,8 +89,8 @@
10989
:)
11090
</ListViewItem>
11191
</ListView>
112-
<TextBlock Style="{StaticResource MaterialDesignTitleTextBlock}" Grid.Row="4" Margin="0 32 0 0">ListView.GridView</TextBlock>
113-
<ListView Grid.Row="5" ItemsSource="{Binding Items1}">
92+
<TextBlock Style="{StaticResource MaterialDesignTitleTextBlock}" Margin="0 32 0 0">ListView.GridView</TextBlock>
93+
<ListView ItemsSource="{Binding Items1}">
11494
<ListView.View>
11595
<GridView>
11696
<GridViewColumn DisplayMemberBinding="{Binding Code}" Header="Code" />
@@ -119,6 +99,6 @@
11999
</GridView>
120100
</ListView.View>
121101
</ListView>
122-
</Grid>
123-
102+
</codeDisplayer:XamlDisplayerPanel>
103+
124104
</UserControl>

MainDemo.Wpf/Lists.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Windows.Media.Imaging;
1313
using System.Windows.Navigation;
1414
using System.Windows.Shapes;
15+
using MaterialDesignDemo.Helper;
1516

1617
namespace MaterialDesignColors.WpfExample
1718
{
@@ -23,6 +24,7 @@ public partial class Lists : UserControl
2324
public Lists()
2425
{
2526
InitializeComponent();
27+
XamlDisplayerPanel.Initialize(new SourceRouter(this.GetType().Name).GetSource());
2628
}
2729
}
2830
}

0 commit comments

Comments
 (0)