【发布时间】:2021-09-05 12:46:50
【问题描述】:
通过添加更改 listView 中按钮的 BindingContext 时
BindingContext="{Binding Source={x:Reference parentContePage}}"
Command="{Binding ViewPdf}"
由于某种原因,应用程序试图在视图类中查找方法,而我在输出控制台中遇到错误
[0:] Binding: 'ViewPdf' property not found on 'WinterEventMobileForm.UI.Pages.ReservationView'
parentContePage 元素
<views:MvxContentPage xmlns="http://xamarin.com/schemas/2014/forms"
x:Name="parentContePage"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:TypeArguments="viewModels:ReservationViewModel"
xmlns:views="clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms"
xmlns:viewModels="clr-namespace:WinterEventMobileForm.Core.ViewModels;assembly=WinterEventMobileForm.Core"
xmlns:navigationdrawer="clr-namespace:Syncfusion.SfNavigationDrawer.XForms;assembly=Syncfusion.SfNavigationDrawer.XForms"
xmlns:buttons="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
xmlns:view="clr-namespace:WinterEventMobileForm.UI.Pages"
xmlns:ListView="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"
xmlns:core="clr-namespace:Syncfusion.XForms.Core;assembly=Syncfusion.Core.XForms"
x:Class="WinterEventMobileForm.UI.Pages.ReservationView"
xmlns:controls="clr-namespace:WinterEventMobileForm.UI.Controls" xmlns:border="clr-namespace:Syncfusion.XForms.Border;assembly=Syncfusion.Core.XForms"
Title="test"
NavigationPage.HasNavigationBar="False"
xmlns:mvx="clr-namespace:MvvmCross.Forms.Bindings;assembly=MvvmCross.Forms"
>
为什么 x:Reference 返回 View 而不是 ViewModel?
【问题讨论】: