zoukankan      html  css  js  c++  java
  • WPF 一些容易忘记的控件属性

    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

  • 相关阅读:
    在阿里云centos7.6上部署vue.js2.6前端应用
    gRPC
    Docker
    ES6、ES7、ES8、ES9、ES10
    HTTPS工作原理 HTTP协议数据结构分析 HTTP和HTTPS协议的不同之处
    SpringBean的工作原理
    Nginx负载均衡高可用---架构
    集群的负载策略
    redis 和 memcached的区别
    Django的基础教程
  • 原文地址:https://www.cnblogs.com/yangleiWPF/p/1716405.html
Copyright © 2011-2022 走看看