zoukankan      html  css  js  c++  java
  • WPF小记 -- 使用Path自己画图标,点击命中(焦点)丢失问题

    在Template中,Path外面的Grid需添加Background属性值。否则点击范围会受限制,例如:Click,在RadioButton的Height和With范围内点击,命中率<1。

     <Style TargetType="{x:Type RadioButton}">
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RadioButton}">
                        <!--  Grid加上Background属性,点击命中不会丢失  -->
                        <Grid
                            x:Name="templateRoot"
                            Margin="5"
                            Background="Transparent"
                            SnapsToDevicePixels="True">
                            <Path
                                Name="path"
                                Width="20"
                                Height="20"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Data="M100.9,100.307 L181.5,100.307 181.5,180.60001 100.9,180.60001 z M0.5,100.307 L81.099999,100.307 81.099999,180.60001 0.5,180.60001 z M100.9,0.5 L181.5,0.5 181.5,80.793 100.9,80.793 z M0.50000539,0.5 L81.100006,0.5 81.100006,80.793 0.50000539,80.793 z"
                                Fill="#AAAAAA"
                                Stretch="Fill" />
                            <ContentPresenter
                                x:Name="contentPresenter"
                                Margin="{TemplateBinding Padding}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Focusable="False"
                                RecognizesAccessKey="True"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="true">
                                <Setter TargetName="path" Property="Fill" Value="#5A84F3" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
  • 相关阅读:
    21. Node.Js Buffer类(缓冲区)-(一)
    20.Node.js EventEmitter的方法和事件
    19.Node.js EventEmitter
    18.Node.js 事件循环
    17.Node.js 回调函数--异步编程
    16.REPL 命令
    15.Node.js REPL(交互式解释器)
    14.NPM 常用命令
    **PHP Notice: Undefined index:...问题的解决方法
    **CI中的order_by在get_where之前
  • 原文地址:https://www.cnblogs.com/kuangxiangnice/p/8422018.html
Copyright © 2011-2022 走看看