【发布时间】:2013-07-03 19:33:54
【问题描述】:
我正在尝试在 C++/CX 中绑定到 Windows 应用商店应用程序(使用 Visual Studio 2013 编译器编译)中的 GridLength 实例,但由于某种原因,我在运行时不断收到以下错误:
Error: Converter failed to convert value of type 'Windows.Foundation.IReference`1<Windows.UI.Xaml.GridLength>' to type 'GridLength'; BindingExpression: Path='MyHeight' DataItem='MyNamespace.MyObject'; target element is 'Windows.UI.Xaml.Controls.RowDefinition' (Name='null'); target property is 'Height' (type 'GridLength').
我的代码基本上看起来像:
namespace MyNamespace
{
[Windows::UI::Xaml::Data::Bindable]
public ref class MyObject sealed
{
property Windows::UI::Xaml::GridLength MyHeight
{
Windows::UI::Xaml::GridLength get() { return myHeight; }
}
}
}
我的 XAML 文件基本上看起来像:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="{Binding MyHeight}"/>
</Grid.RowDefinitions>
</Grid>
仅供参考,我班级中的其他属性已正确绑定。问题似乎仅与 GridLength 值结构有关。它显然是正确地找到了属性,但由于某种原因它无法匹配类型。
【问题讨论】:
标签: windows-runtime windows-store-apps c++-cx