Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add Controls To Grid At Runtime
Message
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01464044
Message ID:
01464064
Views:
26
>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;
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform