This is a migrated thread and some comments may be shown as answers.

How to bind RadPanelBar to View with graphics in WPF MVVM application.

2 Answers 19 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Eugene
Top achievements
Rank 1
Eugene asked on 04 Feb 2016, 12:13 PM
I have an WPF MVVM Catel project with five Views: View_1, View_2, View_3, View_4 and View_5. Each View is implemented as catel:UserControl and has appropriate Model and ViewModel. There is a telerik:RadCartesianChart presenting diagram changing in real time in each View. There is also a catel:Window in my application that is the application main window. There is RadPanelBar in the application main window XAML. This RadPanelBar has five instances of telerik:RadPanelBarItem in XAML. I'm in need of binding of each telerik:RadPanelBarItem to appropriate View. For example: first RadPanelBarItem to View_1, the second one to View_2 e.t.c. Please give me a reference to example of that binding. Thank you very much in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 08 Feb 2016, 11:09 AM
Hello Eugene,

RadPanelBar works with hierarchical data, which means that its RadPanelBarItems are not content controls but item controls. Therefore, in order to display a user control in a RadPanelBarItem you will need to add it in its Items collection. 

In your case you can add the user controls with the chart using the following syntax:
<telerik:RadPanelBarItem>
    <local:View1 />
</telerik:RadPanelBarItem>
<telerik:RadPanelBarItem>
    <local:View2 />
</telerik:RadPanelBarItem>
....
The equivalent for this declaration in code is the following:
var panelBarItem1 = new RadPanelBarItem();
var panelBarItem2 = new RadPanelBarItem(); 
panelBarItem1.Items.Add(new View1());
panelBarItem2.Items.Add(new View2());

You can also consider using data binding to populate the panelbar with items. For example, you can store the viewmodels of the user controls into a collection and bind it to the ItemsSource of the panelbar control. Then define few DataTemplates with the different views (UserControls) and use DataTemplateSelector to decide which templates should be used depending on the items in the ItemsSource collection. You can also take a look at the RadPanelBar Data Binding demo.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Eugene
Top achievements
Rank 1
answered on 28 Mar 2016, 06:03 AM
Thank you very much for your help.
Tags
PanelBar
Asked by
Eugene
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Eugene
Top achievements
Rank 1
Share this question
or