, , ItemTemplate. , , .
: DisplayMemberPath, ItemTemplate, .
, , (, ), - DataContext :
<ComboBox ItemsSource="..." SelectedValuePath="...">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding }" TextTrimming="CharacterEllipsis" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
.
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding }" TextTrimming="CharacterEllipsis" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
, , , DisplayMemberPath, , , . , :
<TextBlock Text="{Binding MyDisplayMemberProperty}" TextTrimming="CharacterEllipsis" />
, ComboBox. , :
<DataTemplate DataType="{x:Type namespace:MyItemType}">
</DataTemplate>
This will give you hints for object properties when you write code inside DataTemplate.
source
share