I have a nested user control ( user control in other user control ) . Suppose that User Control 2 is in User Control 1 ,
I'm trying to set the Dependency property of TextDependesce in the User Control 1 ,
what I have exactly: The User Control 2 contains Dependency property as shown
I'm trying to send the parameter from user control 1 into user control 2 in xaml code .
What I mean exactly set the Dependency property of TextDependesce in the other User Control 1.
how can I do that?
Note : the problem is that the TextDependecse will always take null because that the User Control 2 will initialize before the User Control 1 and this was tested using Debugging with break points , I'm searching for a solution to take the value in the user Control 1.
I will give an example :
Suppose that the User Control 1 is button and the user Control 2 is a Window , I need to set the text of button from user Control 2 , what I have as approach is send a parameter of the button text from user Control 1 to user Control 2 in order to modify it inside the UC1 that is supposed a Window .
What I have tried:
public partial class UC_Control2 : UserControl, INotifyPropertyChanged
{
public string TextDependecse
{
get { return (string)GetValue(TextDependecseProperty); }
set { SetValue(TextDependecseProperty, value); }
}
public static readonly DependencyProperty TextDependecseProperty =
DependencyProperty.Register(@"TextDependecse", typeof(string), typeof(UC_Control2), new PropertyMetadata(String.Empty));
<pre>
<local1:UC_Control1 toog="False" TextDependecse="test1"
DockPanel.Dock="Top" Height="30" Width="160" FlowDirection="LeftToRight"
Grid.Row="0" Grid.Column="2"
/>