【发布时间】:2012-05-17 21:07:54
【问题描述】:
我在这里使用 ListBox 和 ListBox 样式:http://viblend.com/products/net/wpf/controls/free-wpf-controls.aspx
看起来像这样:
<ListBox x:Name="listBox" ItemsSource="{Binding}" Style="{StaticResource Office2010SilverListBoxStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem Style="{StaticResource Office2010SilverListBoxItemStyle}" Content="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
但是,如果我单击一个项目,它不会被标记为选定项目。 如果我不使用数据模板,一切正常。那么有人知道为什么吗? 这里是工作示例:
<ListBox x:Name="listBox" Style="{StaticResource Office2010SilverListBoxStyle}">
<ListBoxItem Style="{StaticResource Office2010SilverListBoxItemStyle}">1. Frame</ListBoxItem>
<ListBoxItem Style="{StaticResource Office2010SilverListBoxItemStyle}">2. Frame</ListBoxItem>
<ListBoxItem Style="{StaticResource Office2010SilverListBoxItemStyle}">3. Frame</ListBoxItem>
<ListBoxItem Style="{StaticResource Office2010SilverListBoxItemStyle}">4. Frame</ListBoxItem>
<ListBoxItem Style="{StaticResource Office2010SilverListBoxItemStyle}">5. Frame</ListBoxItem>
<ListBoxItem Style="{StaticResource Office2010SilverListBoxItemStyle}">6. Frame</ListBoxItem>
</ListBox>-->
【问题讨论】: