Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Add Controls To Grid At Runtime
Message
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01464044
Message ID:
01464064
Vues:
25
>I'm in a WPF app, and I want to add controls to a grid at runtime. I have:
>
>
>private void LoadView(ViewModelBase View)
>{
>    Type ViewType = View.GetType();
>
>    switch (ViewType.Name.ToLower())
>    {
>        case "groupviewmodel":
>            CurrentView = new GroupViewModel();
>            CurrentControl = new crlGroupView();
>            break;
>
>        case "ruleviewmodel":
>            CurrentView = new RuleViewModel();
>            CurrentControl = new crlRuleTree();
>            break;
>    }
>
>    CurrentControl.DataContext = CurrentView;
>
>    grdMain.Children.Add(CurrentControl);
>    Grid.SetRow(CurrentControl, 1);
>    Grid.SetColumn(CurrentControl, 0);
>    grdMain.Children.Add(CurrentControl);
>}
>
>
>The control does not appear. Anyone know what's wrong?

CurrentControl.Visibility = Visibility.Visible;
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform