Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将光标设置为手动控制空图像_C#_Wpf_Xaml - Fatal编程技术网

C# 将光标设置为手动控制空图像

C# 将光标设置为手动控制空图像,c#,wpf,xaml,C#,Wpf,Xaml,我有以下xaml: <Border x:Name="brdImg3" BorderThickness="2" BorderBrush="Black" Margin="10,5,5,5" Cursor="Hand"> <Image x:Name="image3" Stretch="Fill" Cursor="Hand"/> </Border> 问题是,手动光标仅在图像源不为空时显示。当源为空时,仅当鼠标位于边框上方时,才会显

我有以下xaml:

    <Border x:Name="brdImg3" BorderThickness="2" BorderBrush="Black" Margin="10,5,5,5" Cursor="Hand">
        <Image x:Name="image3" Stretch="Fill" Cursor="Hand"/>
    </Border>


问题是,手动光标仅在图像源不为空时显示。当源为空时,仅当鼠标位于边框上方时,才会显示手动光标。当鼠标在边框中时,我需要显示手动光标。如何执行此操作?

在游标中使用转换器,检查源是否为null或空。逻辑是写出来的

Cursor={Binding Source,Converter={StaticResources CursorConverter}

 public class CursorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!string.IsNullorEmpty(value.Tostring()))
            {
                return Cursor.Hand;
            }
            else
            {
                return Cursor.Arrow;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

背景=边界透明这是我需要的解决方案。非常感谢。