Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF: Basic Binding Question on UserControl with respect to two way mode

$
0
0

Hi,

I will try to be as clear as possible :-

1. I have a Usercontrol with a TextBox (It has its own View Model) - I

2. I have another UserControl which references the above one (It also has its own View Model)- II

Roughly, this is what the XAML looks for UserControl2 (which references UserControl1) -Please ignore the specifics.

<UserControl x:Class="MyClass" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Controls:UserControl1 DockPanel.Dock="Bottom"

DescriptionUserControl1="{Binding Description, Mode=TwoWay,

UpdateSourceTrigger=PropertyChanged}" /></UserControl>


The Description propertyis exposed via UserControl2's ViewModel which in turn Binds to the "DependencyProperty" of UserControl1.

Question: When the user types on the TextBox, I want theDescription property of UserControl2's View Model to get updated. I have tried making the Description property as a dependency property but no luck. Whenever I type, it always updates its own Dependency Property i.e. of the UserControl 1 itself - which I don't care. But during binding (on load) it binds perfectly. But, other way is not working. Basically, the changes of textbox should reflect back to UserControl2, ViewModel.

Hope I am clear.




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>