【发布时间】:2010-02-04 21:09:50
【问题描述】:
我正在尝试将 IsLoading 属性绑定到我的 UI 的 LayoutRoot Grid 的 Cursor 属性。每当属性说正在加载时,我都试图让主应用程序光标变成沙漏。
我将属性绑定如下:
<Grid Cursor="{Binding IsLoading, Converter={StaticResource CursorConverter}}">
“CursorConverter”键映射到资源中的 BoolToCursorConverter。转换器代码为:
public class BoolToCursorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (parameter == null)
return ((bool)value == true) ? Cursors.Wait : Cursors.Arrow;
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
Cursor cursor = value as Cursor;
if (cursor != null)
return cursor == Cursors.Wait ? true : false;
return false;
}
}
当我尝试运行它时,虽然我得到 XamlParseException "The given key was not present in the dictionary."
任何帮助将不胜感激,谢谢,
【问题讨论】:
标签: c# silverlight xaml silverlight-3.0