zip's

while(true) { Write it down; Think about it; Refine it; Sleep(); }

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
拖动Item
 
选择已经选中的Item
选择一个已经选中的 item :有时,需要处理选择一个已经选中的 item,可是这时 SelectionChanged 不会被再次触发。一个解决方法是,用 EventSetter 将 item 的事件代理出去。
<ListBox SelectionChanged="ListBox_SelectionChanged">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBox_MouseLeftButtonDown"/>
</Style>
</ListBox.ItemContainerStyle>
<TextBlock Text="qwer"/>
<TextBlock Text="asdf"/>
<TextBlock Text="zxcc"/>
</ListBox>
参考:
 
 
改变选中项目的背景色
<!--change background of selected item-->
<ListBox>
<ListBox.Style>
<Style>
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Green" />
</Style.Resources>
</Style>
</ListBox.Style>
<TextBlock Text="customized background color"/>
</ListBox>
to be continued ...
posted on 2011-03-02 10:26  zip's  阅读(794)  评论(0编辑  收藏  举报