Tuesday, September 13, 2011

Myth Self Note 6: C# WPF - clear parent

1 - image above is a "usercontrol" which is included in another stack 'stkBody'
2 - motive : want to clear stack 'stkMain' when button 'btnStart' is clicked

Code:
((StackPanel)stkLeft.Parent).Children.Clear;

*stkLeft or stkRight, each can be use because we want to select its parent.

3 - motive : want to remove 'stkLeft' when 'btnStart' is clicked

Code:
((StackPanel)stkLeft.Parent).Children.Remove(stkLeft);


themythstoodstill: in btnStart_Click event, can't access the stkMain.

0 comments: