C# 将光标设置为手动控制空图像
我有以下xaml: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> 问题是,手动光标仅在图像源不为空时显示。当源为空时,仅当鼠标位于边框上方时,才会显
<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();
}
}
背景=边界透明这是我需要的解决方案。非常感谢。