0

I have a xaml text block defined like this:

 <TextBlock HorizontalAlignment="Left" Margin="307,43,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="105" Width="230" Text="{Binding Supplier}"/>

I'm trying to bind to the property Supplier.

My constructor for the Xaml window code-behind class:

InitializeComponent();
viewModel = new NewOrderViewModel();
DataContext = viewModel;

There I explicitly set DataContext to be my viewModel object, which contains Supplier property.

And my viewModel prop:

public SupplierDto Supplier
        {
            get
            {
                return supplier;
            }
            set
            {
                supplier = value;
            }
        }

Isn't this all I have to do (set DataContext to an appropriate object), and have all public properties available for binding as I see fit?

Mefhisto1
  • 2,188
  • 7
  • 34
  • 73
  • possible duplicate of [WPF TextBlock text Binding](http://stackoverflow.com/questions/14624373/wpf-textblock-text-binding) – MethodMan Dec 01 '14 at 15:04

1 Answers1

2

Your viewmodel has to implement INotifyPropertyChanged and you have to call NotifyPropertyChanged() method in Supplier setter.

user2250152
  • 14,658
  • 4
  • 33
  • 57