C# 绑定Usercontrol的datacontext
我从wpf应用程序开始。我正在尝试实践MVVM模式。绑定Usercontrol的datacontext时遇到问题C# 绑定Usercontrol的datacontext,c#,windows-phone-8,mvvm,datacontext,C#,Windows Phone 8,Mvvm,Datacontext,我从wpf应用程序开始。我正在尝试实践MVVM模式。绑定Usercontrol的datacontext时遇到问题 <UserControl x:Class="Test.Views.Login.Identifer" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://sch
<UserControl x:Class="Test.Views.Login.Identifer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:Test.ViewModels"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<UserControl.DataContext>
<vm:Login/>
</UserControl.DataContext>
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox Name="user"></TextBox>
<TextBox Grid.Row="1" Name="password"></TextBox>
</Grid>
我有以下错误:
错误1无法创建类型为“Test.ViewModels.Login”的实例[行:14位置:19]
谢谢你的帮助。你的课程应该是公开的,但却是私人的
public class Login : MyNotifyPropertyChanged //add public keyword
using Test.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test.ViewModels
{
class Login : MyNotifyPropertyChanged
{
public Client client_ { get; set; }
public Login()
{
client_ = new Client();
}
}
}
public class Login : MyNotifyPropertyChanged //add public keyword