vs WPF dünyaya oldukça yeni ve ben bir ItemsControl yılında şablon öğeleri ile bazı sorunlarım var. Ne gereken bir ItemsControl (veya benzeri) içindeki şablon elemanları (çoğunlukla düğmeleri) etmektir. http://img444.imageshack.us/img444/2167/itemscontrolnottemplate.gifıtemtemplate: ListBox ItemsControl
ItemsControl ya Düğme şablonu uygulamak vermedi:
Aşağıdaki XAML kodu kullanıyorum olursa ...
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type Button}">
<Border BorderBrush="AliceBlue"
BorderThickness="3">
<TextBlock Text="Templated!"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<Button>Not templated</Button>
<TextBlock>Text not templated</TextBlock>
</ItemsControl>
... Bu sonuç almak ne de TextBlock kontrole. Böyle bir ListBox içine ItemsControl değiştirirseniz:
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type Button}">
<Border BorderBrush="AliceBlue"
BorderThickness="3">
<TextBlock Text="Templated!"/>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
<Button>Not templated</Button>
<TextBlock>Text not templated</TextBlock>
</ListBox>
... Ben bu sonucu alıyorum sonra:
img814.imageshack.us/img814/6204/listboxtoomuchtemplatin.gif Şimdi şablonu (I Düğme sadece olmak DataType set bile) İKİ çocuk kontrolleri uygulanır.