zoukankan      html  css  js  c++  java
  • 剪切具有CornerRadius的RectangleGeometry(可能在Ripple中用到)

    剪切具有CornerRadius的RectangleGeometry(可能在Ripple中用到)

    1、新建Converter

    public class BorderClipConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length == 3 && values[0] is double && values[1] is double && values[2] is CornerRadius)
            {
                var width = (double)values[0];
                var height = (double)values[1];
    
                if (width < Double.Epsilon || height < Double.Epsilon)
                {
                    return Geometry.Empty;
                }
    
                var radius = (CornerRadius)values[2];
    
                 var clip = new System.Windows.Media.RectangleGeometry(new Rect(0, 0, width, height), radius.TopLeft, radius.TopLeft);
                clip.Freeze();
    
                return clip;
            }
    
            return DependencyProperty.UnsetValue;
        }
    
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    } 

    2、添加Converter

    <controls:Ripple.Clip>
                                    <MultiBinding Converter="{StaticResource BorderClipConverter}">
                                        <Binding Path="ActualWidth" ElementName="border" />
                                        <Binding Path="ActualHeight" ElementName="border" />
                                        <Binding Path="CornerRadius" ElementName="border" />
                                    </MultiBinding>
                                </controls:Ripple.Clip>
     
  • 相关阅读:
    AppDomain and related
    实现 Finalize 和 Dispose 以清理非托管资源
    递归显示treeview,求更好方法
    SQL练习题之子查询
    jquery in action 学习笔记
    daily english 201117
    TOP AND APPLY
    Create trace with tsql
    (转)sqlserver 锁查看
    一个简单的windows services demo(c#)
  • 原文地址:https://www.cnblogs.com/akiing/p/7493358.html
Copyright © 2011-2022 走看看