wpf - how to replace the content of the parent control from child user control in code behind -


I am writing something in the code behind auditInventoryViews: Scheduler to change the content of the content content: User control "control" DSViewContentControl "I tried with" This.content ", but it only changes the contents of the current user control and the other content still remains in the usercontrol.

So the thing is how do I Can change the contents of original control from behind code

Sample code for example

  & lt; UserControl & gt; ContentControl x: name = "DSViewContentControl" & gt; & lt; grid & gt; & Lt; Grid.RowDefinitions & gt; RowDefinition /> & lt; RowDefinition / & gt; & lt; /Grid.RowDefinitions> & lt; Grid.ColumnDefinitions & gt; & lt; column Definition Width = " * "& Gt; & lt; / ColumnDefinition & gt; & lt; column deflection width =" * "& gt; & lt; / ColumnDefinition & gt; & lt; /Grid.ColumnDefinitions> & lt ;! - Area Scheduler - & Gt; & lt; StackPlanel Grid Rau = "1" grid. Column = "1" margin = "405,0,0" & gt; Some content & lt; / StackPanel & gt; & Lt; Stackpaneel grid Rau = "1" grid. Column = "1" margin = "405,0,0" & gt; & Lt; AuditInventoryViews: SchedulerView / & gt; & Lt; / StackPanel & gt; & Lt; / Grid & gt; & Lt; / ContentControl> & Lt; / UserControl & gt;  

If you have a parent for parent Can be referred to through the medium. For example DSViewContentControl to scheduler view code-behind:

  to get the StackPainel parent StackPlan = (StackPanel). Parent; Grid grandParentGrid = (grid) parentStackpnl.Parent; ContentControl DSViewContentControl = (ContentControl) grandParentGrid.Parent; // It is straightforward to act on DSViewContentControl at this point  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -