zoukankan      html  css  js  c++  java
  • WPF 基础

    类继承图

    命令

    CommandTarget属性可以用来重新设置命令目标

    <StackPanel>
            <TextBox Name="txtSomeText"
                     Width="220" Height="25" Margin="10"/>
            <Button Content="Paste"
                    Command="ApplicationCommands.Paste"
                    CommandTarget="{Binding ElementName=txtSomeText}"
                    Margin="10" Padding="10,3"
                    HorizontalAlignment="Center" />
        </StackPanel>

    本例点击按钮时,文本框会自带粘贴,不需要后台代码

     另一个场景就是上下文菜单

    <MenuItem Command="{x:Static loc:MainWindow.GreetUserCommand}"
              CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"/>

    文本格式

    <TextBlock Margin="10" Height="100" FontSize="14" Width="290" TextWrapping="Wrap">
                We <Bold>few</Bold>, we happy <Bold>few</Bold>, we band of <Underline>brothers</Underline>;
    For he to-day that sheds his <Italic>blood</Italic> with me
    Shall be my <Underline>brother</Underline>; be he ne'er so <Italic>vile</Italic>,
    This day shall <Bold>gentle</Bold> his <Italic>condition</Italic>;"
            </TextBlock>

    ListView 使用 WrapPanel 需要禁用 ListView 的水平滚动,才能实现自动换行

  • 相关阅读:
    C语言volatile关键字的用法
    UDP广播包
    进程和线程的区别
    Unix/Linux进程间通信
    虚拟空间,malloc
    自我介绍
    java初始化顺序
    java 队列基础操作
    java IO基础操作
    Python中的Tab补全功能添加
  • 原文地址:https://www.cnblogs.com/yetsen/p/13585990.html
Copyright © 2011-2022 走看看