In my WPF XAML form, I have many elements that I bind to my properties.
For each property, I do the following steps:
<TextBlock Grid.Column="0" Grid.Row="0" Name="TB11" Text="{Binding TBX11}"
VerticalAlignment="Center" HorizontalAlignment="Center"
DataContext="{Binding RelativeSource={RelativeSource Self}}" />
and
#region TBX11
private static void OnXBPropertyChanged(DependencyObject dependencyObject,
DependencyPropertyChangedEventArgs e)
{
table myUserControl = dependencyObject as table;
myUserControl.OnPropertyChanged("XB11");
myUserControl.OnCaptionPropertyChanged(e);
}
private void OnCaptionPropertyChanged(DependencyPropertyChangedEventArgs e) {
TB11.Text = TBX11;
}
public static readonly DependencyProperty TBX11Property =
DependencyProperty.Register("TBX11", typeof(string), typeof(table),
new PropertyMetadata(string.Empty, OnXBPropertyChanged));
public string TBX11 {
get { return GetValue(TBX11Property).ToString(); }
set {
SetValue(TBX11Property, value);
OnPropertyChanged("TBX11");
}
}
#endregion
I canβt even understand how many times I will need to write the same thing here, but I donβt know if I can make it any easier? Because all I need to install here is the name of the WPF block and the name of the binding.
source
share