निम्नलिखित कोड में, मैं कॉम्बोबॉक्स को डेटाटेम्प्लेट नामक डेटा टेम्पलेट का उपयोग करने के लिए आइटम टेम्पलेट विशेषता निर्दिष्ट करके बताता हूं।मैं आइटम टेम्पलेट का उपयोग करने के लिए स्टैकपैनेल कैसे प्राप्त कर सकता हूं?
स्टैकपैनल, हालांकि, कोई आइटम टेम्पलेट विशेषता नहीं है।
मैं ग्राहक टेम्पलेट का उपयोग करने के लिए स्टैकपैनल कैसे प्राप्त कर सकता हूं?
<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>
सही, एक और उपयोगी नियंत्रण लकड़ी से बाहर क्रॉल, धन्यवाद –
वोट दें Clippy टिप्पणी के लिए :) – Flater