Skip to content

Commit 8822f63

Browse files
committed
Update BasicControlsExample
Mode 2 add DataGridTemplateColumn ComboBox
1 parent 3de6c98 commit 8822f63

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,18 @@
561561
Binding="{Binding Address}"
562562
Header="Address"
563563
IsReadOnly="True" />
564+
<DataGridTemplateColumn Width="*" Header="ContactMethod">
565+
<DataGridTemplateColumn.CellEditingTemplate>
566+
<DataTemplate>
567+
<ComboBox ItemsSource="{x:Static local:BasicControlsExample.ContactMethods}" SelectedItem="{Binding ContactMethod, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
568+
</DataTemplate>
569+
</DataGridTemplateColumn.CellEditingTemplate>
570+
<DataGridTemplateColumn.CellTemplate>
571+
<DataTemplate>
572+
<TextBlock Text="{Binding ContactMethod}" />
573+
</DataTemplate>
574+
</DataGridTemplateColumn.CellTemplate>
575+
</DataGridTemplateColumn>
564576
</DataGrid.Columns>
565577
</DataGrid>
566578
</TabItem>

src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public partial class BasicControlsExample : UserControl
3131
DependencyProperty.Register("AllSelected", typeof(bool), typeof(BasicControlsExample),
3232
new PropertyMetadata(AllSelectedChangedCallback));
3333

34+
public static List<string> ContactMethods { get; } = new List<string> { "Tel", "Fax", "MB" };
3435
public BasicControlsExample()
3536
{
3637
InitializeComponent();
@@ -54,6 +55,7 @@ private void MainView_Loaded(object sender, RoutedEventArgs e)
5455
Date = time,
5556
Name = "WPFDevelopers",
5657
Address = "One Microsoft Way, Redmond",
58+
ContactMethod = "MB",
5759
Children = new List<UserModel>
5860
{
5961
new UserModel { Name = "WPFDevelopers1.1",Children=new List<UserModel>

src/WPFDevelopers.Samples.Shared/Models/UserModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public bool IsChecked
2121
public DateTime Date { get; set; }
2222
public string Name { get; set; }
2323
public string Address { get; set; }
24+
public string ContactMethod { get; set; }
2425
public List<UserModel> Children { get; set; }
2526
}
2627
}

0 commit comments

Comments
 (0)