Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 绑定Usercontrol的datacontext_C#_Windows Phone 8_Mvvm_Datacontext - Fatal编程技术网

C# 绑定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

我从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://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