U
U
Untiwe2021-05-19 20:38:47
WPF
Untiwe, 2021-05-19 20:38:47

How to set data binding from more than one source?

I managed to bind data to fields, an instance of a class

public MainWindow(){
this._chamber = new CameraFeutron();
this.DataContext = _chamber;
InitializeComponent();
}

And implement in code
<TextBox Text="{Binding current_temperature}" />
 <TextBox Text="{Binding current_humidity}" />
<TextBox Text="{Binding set_temperature}" />
<TextBox Text="{Binding set_humidity}" />


Now I also have the "Ratronic_communicator" class, but I don't understand how to add it to the context, or bind it in another way.
this._chamber = new CameraFeutron();
this.DataContext = _chamber;
this.DataContext += Ratronic_communicator;
naturally does not work.

I wanted to make a binding through xaml
<TextBox Text="{Binding Source=Ratronic_communicator, Path=temperature}" />

But here the error "String The temperature property was not found for an object of type String" takes off, although the property is 100%

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LiptonOlolo, 2021-05-22
@Untiwe

What you want to do is called ViewModel. Put all the necessary properties in one class and bind to them without problems, there will be tons and billions of examples on the Internet at the request of MVVM Example. Here is an example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question