基本上,我不是把我的loginpageviewmodel放在我的viewmodels文件夹中,而是把它嵌套在viewmodels文件夹中的startup文件夹中,所以我想知道如何在这里更新该引用:viewModels:LoginPageViewModel ',这样我就不会得到上面的错误了。
gjmwrych1#
假设文件路径为ViewModels--> StartUp--> LoginViewModel.cs。然后,您可以在页面上添加命名空间:
ViewModels
StartUp
LoginViewModel.cs
xmlns:startup="clr-namespace:YourAppName.ViewModels.StartUp"
如下所示:
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:startup="clr-namespace:YourAppName.ViewModels.StartUp" x:Class="YourAppName.LoginPage"> <ContentPage.BindingContext> <startup:LoginViewModel></startup:LoginViewModel> </ContentPage.BindingContext> <ContentPage.Content> <StackLayout> <Label Text="Welcome to First Page!" VerticalOptions="Start" HorizontalOptions="CenterAndExpand" /> </StackLayout> </ContentPage.Content> </ContentPage>
1条答案
按热度按时间gjmwrych1#
假设文件路径为
ViewModels
-->StartUp
-->LoginViewModel.cs
。然后,您可以在页面上添加命名空间:
如下所示: