0
VB.Net'in jeneriklerini sadece Wpf'ye bildirilebilir sınırlı denetimler için kullanabilir miyim?Generic'leri Basit Wpf Bildirilebilir Bağlamalar'a kullanabilir miyim?
VB.Net'in jeneriklerini sadece Wpf'ye bildirilebilir sınırlı denetimler için kullanabilir miyim?Generic'leri Basit Wpf Bildirilebilir Bağlamalar'a kullanabilir miyim?
VB.Net'in Generics'i, bildirilebilir sınırlı denetimler oluşturmak için nasıl kullanılır.
Class MainWindow
Public Sub New()
InitializeComponent()
Me.DataContext = Me
End Sub
Public Property NoNotify As String = "No notify"
Public Property DoesNotify As New NotifiableProperty(Of String)("DoesNotify")
Private Sub TestBtn_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles TestBtn.Click
NoNotify = "Won't Show"
DoesNotify.Value = "Notified!"
End Sub
End Class
Public Class NotifiableProperty(Of T)
Implements System.ComponentModel.INotifyPropertyChanged
Sub New()
End Sub
Sub New(ByVal InitialValue As T)
value = InitialValue
End Sub
Private m_Value As T
Public Property Value As T
Get
Return m_Value
End Get
Set(ByVal value As T)
m_Value = value
RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs("Value"))
End Set
End Property
Private Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
End Class
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<StackPanel>
<Button Name="TestBtn" Content="Click to Test" Width="72" />
<TextBox Name="NoNotifyTB" Text="{Binding NoNotify}" />
<TextBox Name="DoesNotifyTB" Text="{Binding DoesNotify.Value}"/>
</StackPanel>
</Grid>
</Window>
'DoesNotify' özelliği' ReadOnly' olmalıdır. – SLaks
Sorularınıza cevap kabul etmelisiniz. – SLaks