简体   繁体   中英

using x:Bind with MvvmCross

while trying to code the TipCalc example in MvvmCross, i try to use x:Bind instead of the regular Binding (In universal application programming)

my code behind looks like this:

public sealed partial class TipView 
{
    public new TipViewModel ViewModel
    {
        get { return (TipViewModel)base.ViewModel; }
        set { base.ViewModel = value; }
    }

    public TipView()
    {
        this.InitializeComponent();
    }
}

and my xaml looks like this:

<Grid x:Name="ContentPanel" 
          Margin="12,0,12,0"
          Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
          >
        <StackPanel>
            <TextBlock
                Text="SubTotal"
                />
            <TextBox 
                Text="{x:Bind ViewModel.SubTotal, Mode=TwoWay}" 
                />
.
.
.

when compiling this i get the following error:

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'.

i'm using the MvvmCross libs of 3.5.1 version (last stable)

is it a bug ? or something i am missing here ?

I use following syntax in my code

public TipViewModel Vm => (TipViewModel) ViewModel;

And the binding would be

Text="{x:Bind Vm.SubTotal, Mode=TwoWay}"

Not sure why you would get your error, your view does inherit from MvxWindowsPage ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM