Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To: Subclass User Control
Message
From
05/05/2011 17:31:46
 
 
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01470880
Message ID:
01509747
Views:
47
>Hi,
>To just answer the question: Since you can't have XAML you would have to do it in code. e.g:
public _ViewBase()
>        {
>            StackPanel sp = new StackPanel();
>            Button b = new Button();
>            b.Content = "Click me";
>            sp.Children.Add(b);
>            this.Content = sp;
>        }
>But I agree with John - from a WPF POV this is very unlikely to be the right approach. Are you using MVVM for this app?

I don't think that would work. As soon as you add content to the UserControl it's going to replace your stack panel.

You could do it with view injection.

* Wait till the control is fully loaded.
* Detach the contents.
* Add your wrapper.
* Attach the contents to your wrapper.

But I don't recommend that either.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform