Hello. I am trying to bind to a class property in a dock pane, but am having trouble doing so. I can bind to a property on the dock pane, but not as part of a class object. I have read many posts on the internet and it should not be that hard. Here are snippets of what I currently have.
xaml:
d:DataContext="{Binding Path=ui.AddressEditorDockPaneViewModel}">
<TextBox Grid.Row="1" Grid.Column="0" MaxLength="5" x:Name="HseNo" Text="{Binding Path = pointAddress.HseNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Margin="3,3,3,3" TextWrapping="Wrap" VerticalAlignment="Top" Width="50" BorderBrush="Black" BorderThickness=".75" Background="Transparent" Tag=""/>
Back-end c# class in ViewModel (AddressEditorDockPaneViewModel) with HseNo property:
public class PointAddress : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
private static string _HseNo;
public string HseNo
{
get { return _HseNo; }
//set { SetProperty(ref _HseNo, value); }
set
{
if (value == _HseNo)
return;
_HseNo = value.ToString();
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(HseNo)));
}
}
}
Create a new PointAddress object (I have added this part in a couple of different forms (form level variable, and form level variable with creating new in the ShowAsync event):
public PointAddress pointAddress = new PointAddress();
Thank you for helping!!!