Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To: Subclass User Control
Message
De
05/05/2011 17:31:46
 
 
À
05/05/2011 03:37:19
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01470880
Message ID:
01509747
Vues:
46
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform