W poniższym kodzie informuję użytkownika, że należy użyć DataTemplate o nazwie CustomerTemplate, przypisując mu jego atrybut: ItemTemplate.Jak mogę uzyskać StackPanel do używania ItemTemplate?
StackPanel, jednak nie ma atrybutu ItemTemplate.
W jaki sposób można uzyskać StackPanel również używać CustomerTemplate?
<Window.Resources>
<DataTemplate x:Key="CustomerTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding FirstName}"/>
<TextBlock Text=" "/>
<TextBlock Text="{Binding LastName}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<DockPanel LastChildFill="False" Margin="10">
<ComboBox
x:Name="CustomerList"
ItemTemplate="{StaticResource CustomerTemplate}"
HorizontalAlignment="Left"
DockPanel.Dock="Top"
Width="200"
SelectedItem="{Binding SelectedCustomer, Mode=TwoWay}"
ItemsSource="{Binding Customers}"/>
<StackPanel DataContext="{Binding SelectedCustomer}" Orientation="Horizontal">
<TextBlock Text="Chosen: "/>
<TextBlock Text="{Binding LastName}"/>
</StackPanel>
</DockPanel>
doskonały, kolejny użyteczny kontrola wypełzł stolarki, dzięki –
upvote za komentarz Clippy :) – Flater