【发布时间】:2014-04-13 01:27:22
【问题描述】:
我在 Windows 应用商店应用中有一个转换器类:
namespace MyNamespace {
public class ColorToBrushConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
if (value is Windows.UI.Color) {
Windows.UI.Color color = (Windows.UI.Color) value;
SolidColorBrush r = new SolidColorBrush(color);
return r;
}
CommonDebug.BreakPoint("Invalid input to ColorToBrushConverter");
throw new InvalidOperationException();
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
}
我现在正尝试在 xaml 中使用它。我无法为 xaml 找出正确的语法来告诉它使用我的转换器。
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem" >
<Setter Property="Background" Value="{Binding Source=BackgroundColor, UpdateSourceTrigger=PropertyChanged, Converter=????????????????}"/>
</Style>
</ListView.ItemContainerStyle>
编辑: 显然,Windows 应用商店应用程序不允许开发人员使用在 WPF 中工作的所有数据绑定。这大概解释了我的部分问题。但我仍然不确定在 Windows 8.1 更新后这种情况是否会继续存在。
【问题讨论】:
标签: c# wpf xaml binding windows-store-apps