【发布时间】:2012-03-09 06:40:53
【问题描述】:
我创建了具有静态属性的类。现在我想将所有内容绑定到文本框。但我无法绑定。
具有静态属性的类:
namespace QSys.Library.Security
{
public class CustomerServiceData
{
public static string UserName
{
get
{
return "Imdad";
}
}
}
}
Page.xaml
<UserControl x:Class="QSys.Admin.Views.AdminHomeView"
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:my="clr-namespace:QSys.Library.Security;assembly=QSys.Library"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="640">
<UserControl.Resources>
<my:CustomerServiceData x:Name="mySecurity" />
</UserControl.Resources>
<Grid>
<TextBox Text="{Binding Source={StaticResource mySecurity}, Path=CustomerServiceData.UserName}" ></TextBox>
</Grid>
</UserControl>
谁能告诉我为什么我的文本框中没有得到值?即使它还没有给我任何错误。
谢谢, 伊姆达杜森
【问题讨论】:
标签: silverlight data-binding mvvm