YangLei's

导航

 

1、ListBox:

1>listbox获取静态的Fonts.SystemFontFamilies属性,TextBox绑定SelectedItem。点击listbox选中项时,textbox改变字体

 <ListBox Grid.Row="0" ItemsSource="{x:Static Fonts.SystemFontFamilies}" Margin="5" Name="lstFonts"/>

   <TextBox 
           FontFamily="{Binding ElementName=lstFonts, Path=SelectedItem}"
           TextAlignment="Center" TextWrapping="Wrap">
        The quick brown fox jumps over the lazy dog
      </TextBox>

2>在listBox1_SelectionChanged事件里面选中的是里面的整个子控件,所以需要

 <ListBox  Name="listBox1" Width="120" Height="52"  SelectionChanged="listBox1_SelectionChanged" >

<ListBoxItem Tag="Red">Red</ListBoxItem>

<ListBoxItem Tag="Yellow">Yellow</ListBoxItem>

<ListBoxItem>Blue</ListBoxItem>

</ListBox>

 ((ListBoxItem)listBox1.SelectedItem).Content;可以获取里面的内容:Red,Yellow,Blue。

 ((ListBoxItem)listBox1.SelectedItem).Tag,可以获取Tag值。

<TextBlock Name="textBlock1" Foreground="{Binding ElementName=listBox1,Path=SelectedItem.Content}"  />;用于绑定内容,改变textblock的颜色。

2、Slider

posted on 2010-04-20 17:51  大狼熙熙  阅读(489)  评论(0编辑  收藏  举报