M
M
Misha Prokazin2017-02-09 20:43:38
.NET
Misha Prokazin, 2017-02-09 20:43:38

How to remove parent XAML element?

Started learning UWP with C#. There was a stupid problem.
I have something like this that plays when a button is clicked:

public void NewContent(object sender, RoutedEventArgs e){
            StackPanel NewStack = new StackPanel();
            DatePicker NewDatePicker = new DatePicker();
            TextBox NewInputBox = new TextBox();
            Button RemoveButton = new Button();

            NewStack.Orientation = Orientation.Horizontal;
            NewInputBox.Width = 120;
            RemoveButton.Content = "-";
            RemoveButton.Width = 40;
            RemoveButton.Click += RemoveButton_Click;

            NewStack.Children.Add(NewDatePicker);
            NewStack.Children.Add(NewInputBox);
            NewStack.Children.Add(RemoveButton);
            MainStack.Children.Add(NewStack);}

And I need the RemoveButton_Click handler to remove the entire StackPanel. I thought that it is possible to organize it somehow RemoveButton.Parent.Remove()
But I could not google the "Remove ()" method or similar.
How can I best realize my idea?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2017-02-09
@d-stream

Maybe not destroy, but hide?
And then "I sit on a bitch and drink it"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question