使用 x:Bind 和 MvvmCross
using x:Bind with MvvmCross
尝试在 MvvmCross 中编写 TipCalc 示例时,我尝试使用 x:Bind 而不是常规绑定(在通用应用程序编程中)
我后面的代码是这样的:
public sealed partial class TipView
{
public new TipViewModel ViewModel
{
get { return (TipViewModel)base.ViewModel; }
set { base.ViewModel = value; }
}
public TipView()
{
this.InitializeComponent();
}
}
我的 xaml 看起来像这样:
<Grid x:Name="ContentPanel"
Margin="12,0,12,0"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
>
<StackPanel>
<TextBlock
Text="SubTotal"
/>
<TextBox
Text="{x:Bind ViewModel.SubTotal, Mode=TwoWay}"
/>
.
.
.
编译时出现以下错误:
Microsoft.Windows.UI.Xaml.Common.targets(350,5): Xaml Internal Error error WMC9999: Unable to cast object of type 'Microsoft.MetadataReader.MetadataOnlyPropertyInfo' to type 'System.Reflection.MethodInfo'.
我正在使用 3.5.1 版本的 MvvmCross 库(最后一个稳定版本)
这是一个错误吗?或者我在这里缺少什么?
我在代码中使用了以下语法
public TipViewModel Vm => (TipViewModel) ViewModel;
绑定将是
Text="{x:Bind Vm.SubTotal, Mode=TwoWay}"
不确定为什么会收到错误,您的视图确实继承自 MvxWindowsPage
?
尝试在 MvvmCross 中编写 TipCalc 示例时,我尝试使用 x:Bind 而不是常规绑定(在通用应用程序编程中)
我后面的代码是这样的:
public sealed partial class TipView
{
public new TipViewModel ViewModel
{
get { return (TipViewModel)base.ViewModel; }
set { base.ViewModel = value; }
}
public TipView()
{
this.InitializeComponent();
}
}
我的 xaml 看起来像这样:
<Grid x:Name="ContentPanel"
Margin="12,0,12,0"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
>
<StackPanel>
<TextBlock
Text="SubTotal"
/>
<TextBox
Text="{x:Bind ViewModel.SubTotal, Mode=TwoWay}"
/>
.
.
.
编译时出现以下错误:
Microsoft.Windows.UI.Xaml.Common.targets(350,5): Xaml Internal Error error WMC9999: Unable to cast object of type 'Microsoft.MetadataReader.MetadataOnlyPropertyInfo' to type 'System.Reflection.MethodInfo'.
我正在使用 3.5.1 版本的 MvvmCross 库(最后一个稳定版本)
这是一个错误吗?或者我在这里缺少什么?
我在代码中使用了以下语法
public TipViewModel Vm => (TipViewModel) ViewModel;
绑定将是
Text="{x:Bind Vm.SubTotal, Mode=TwoWay}"
不确定为什么会收到错误,您的视图确实继承自 MvxWindowsPage
?