zoukankan      html  css  js  c++  java
  • WPF学习小记

    WPF通用控制事件

    Click:当控件被单击时发生。某些情况下,当用户按下Enter键时也会发生这样的事件。

    Drop:当拖曳操作完成时发生,也就是说,当用户将某个对象拖曳dao该控件上,然后松开鼠标时发生

    DragEnter:当某个对象被拖曳进入该控件的边缘范围内时发生

    DragLeave:当某个对象呗拖曳出该控件的边缘范围外时发生

    DragOver:当某个对象呗拖曳到控件上时发生

    KeyDown:当该控件具有焦点,并且某个按键被按下时发生。该事件总在KeyPress和KeyUp事件之前发生

    KeyUp:当该控件具有焦点,并且某个按键被释放时发生。该事件总在KeyDowm事件后发生

    GotFocus:当该控件失去焦点时发生。请勿使用该控件对控件执行验证操作。应该改用Validating和Validated

    MouseDoubleClick:当双击该控件时发生

    MouseDown:当鼠标指针经过某个控件,鼠标按钮被按下时发生。该事件与Click事件并不相同,因为MouseDown事件在按钮被按下后,在其释放前发生

    MouseMove:当鼠标经过控件时持续发生

    MouseUp:当鼠标指针经过控件,而鼠标按钮又被释放时发生

    Pancel布局控件

    Canvas——该控件允许以任何合适的方式放置子控件。它不会对子控件的位置施加任何限制,但不会对位置摆放提供任何辅助。

    DockPanel——该控件可以让其中的子控件贴靠到自己四条边中的任意一边。最后一个子控件则可以充满剩余区域。

    Grid——该控件让子控件的定位变得比较灵活。可将该控件的布局分为若干行和若干列,这样就可以在网络布局中对齐控件。

    StackPanel——该控件能够按照水平方向或者垂直方向依次对子控件进行排列。

    WrapPanel——与StackPanel一样,该控件也能够按照水平方向或垂直方向依次对子控件进行排列,但它不是按照一行或一列来排序,而是根据可用空间大小以多行多列的方式排列。

    Canvas:

     <Canvas Background="AliceBlue">
            <Rectangle Canvas.Left="50" Canvas.Top="50" Height="40" Width="100"
                       Stroke="Black" Fill="Chocolate"/>
            <Rectangle Canvas.Left="198" Canvas.Top="121" Height="40" Width="100"
                       Stroke="Black" Fill="Bisque"/>
        </Canvas>

     DockPanel:

    <DockPanel Background="AliceBlue">
            <Border DockPanel.Dock="Top" Padding="10" Margin="5"
                    Background="Aquamarine" Height="45">
                <Label>1) DockPanel.Dock="Top"
                </Label>
            </Border>
            <Border DockPanel.Dock="Top" Padding="10" Margin="5"
                    Background="PaleGoldenrod" Height="45" Width="200">
                <Label>2) DockPanel.Dock="Top"
                </Label>
            </Border>
            <Border DockPanel.Dock="Left" Padding="10" Margin="5"
                    Background="Yellow" Width="200" HorizontalAlignment="Right">
                <Label>3) DockPanel.Dock="Left"
                </Label>
            </Border>
            <Border DockPanel.Dock="Bottom" Padding="10" Margin="5"
                    Background="Bisque" Width="200" HorizontalAlignment="Right">
                <Label>4) DockPanel.Dock="Right"
                </Label>
            </Border>
            <Border Padding="10" Margin="5" Background="BlueViolet">
                <Label Foreground="White">5) Last control
                </Label>
            </Border>
        </DockPanel>

    StackPanel:

     <StackPanel HorizontalAlignment="Left" Height="128" VerticalAlignment="Top" Width="284"
                        Orientation="Horizontal">
                <Button Content="Button" Height="128" VerticalAlignment="Top" Width="75"/>
                <Button Content="Button" Height="128" VerticalAlignment="Top" Width="75"/>
                <Button Content="Button" Height="128" VerticalAlignment="Top" Width="75"/>
            </StackPanel>
            <StackPanel HorizontalAlignment="Left" Height="128" VerticalAlignment="Top"
                        Width="284" Margin="0,128,0,0" Orientation="Vertical">
                <Button Content="Button" HorizontalAlignment="Left" Width="284"/>
                <Button Content="Button" HorizontalAlignment="Left" Width="284"/>
                <Button Content="Button" HorizontalAlignment="Left" Width="284"/>
            </StackPanel>

    WrapPanel:

    <WrapPanel Background="AliceBlue">
            <Rectangle Fill="#FF000000" Height="50" Width="50" Stroke="Black"
                       RadiusX="10" RadiusY="10"/>
            <Rectangle Fill="#FF111111" Height="50" Width="50" Stroke="Black"
                       RadiusX="10" RadiusY="10"/>
            <Rectangle Fill="#FF222222" Height="50" Width="50" Stroke="Black"
                       RadiusX="10" RadiusY="10"/>
            <Rectangle Fill="#FFFFFFFF" Height="50" Width="50" Stroke="Black"
                       RadiusX="10" RadiusY="10"/>
        </WrapPanel>

    注:摘抄自《c#入门经典》

  • 相关阅读:
    树链剖分 关于点权与边权的转换
    2018 CCPC 吉林站 H Lovers || HDU 6562 (线段树哦)
    统计学习方法(一)概念
    python学习心得(三)
    python学习心得
    Python学习:基本概念
    Python学习(一)
    SparkMLlib聚类学习之KMeans聚类
    SparkMLlib回归算法之决策树
    SparkMLlib学习之线性回归
  • 原文地址:https://www.cnblogs.com/tirmer/p/4072109.html
Copyright © 2011-2022 走看看