Reputation: 14684
is it possible to remove a item e.g. a TextBlock
from a StackPanel
and add it to a other StackPanel
?
My XAML Code looks like this:
<StackPanel x:Name="PanelStack1" VerticalAlignment="Bottom" Margin="0,0,0,86">
<Rectangle x:Name="RecX" />
</StackPanel>
<StackPanel x:Name="PanelStack2" VerticalAlignment="Bottom" Margin="0,0,0,86" />
I want to move the RecX
from the PanelStack1
to PanelStack2
via my C# Code. Is this possible?
This is just a small example, in my real code there are many elements which have to been moved.
Upvotes: 0
Views: 404
Reputation: 6445
Try this in your code behind:
PanelStack1.Children.Remove(RecX);
PanelStack2.Children.Add(RecX);
Upvotes: 2