Vb.net Silverlight数据绑定
我的代码里有这个代码Vb.net Silverlight数据绑定,vb.net,silverlight,data-binding,Vb.net,Silverlight,Data Binding,我的代码里有这个代码 Public Shared ReadOnly UsernameProperty As DependencyProperty = DependencyProperty.Register("Username", GetType(String), GetType(LoginControl), Nothing) Public Property Username() As String Get Return CStr(MyBase.
Public Shared ReadOnly UsernameProperty As DependencyProperty = DependencyProperty.Register("Username", GetType(String), GetType(LoginControl), Nothing)
Public Property Username() As String
Get
Return CStr(MyBase.GetValue(UsernameProperty))
End Get
Set(ByVal value As String)
MyBase.SetValue(UsernameProperty, value)
End Set
End Property
然后我在同一页的xaml中有这个
<TextBlock Text="{Binding Path=Username}" Style="{StaticResource WelcomeTextStyle}"/>
但是textblock似乎没有更新其值。您将路径设置为“Username”,但是绑定需要知道在哪个对象上查找该属性。
一种方法是,将DataContext设置为LoginControl。将路径设置为“Username”,但绑定需要知道在哪个对象上查找该属性。
一种方法是将DataContext设置为LoginControl