I am using Hiearchial DataTemplates with normal DataTemplate that i saw in one of the forums in here. But i have a problem when the items are displayed properly but it is not expanded when clicked on the items. here is the code that i am using to Display two items at present.
The Link that i saw this way to display can be found here
XAML:
C# ViewModel
The Link that i saw this way to display can be found here
XAML:
<
Window.Resources
>
<
DataTemplate
x:Key
=
"PanelBarItemTemplate"
>
<
StackPanel
Orientation
=
"Vertical"
>
<
TextBlock
Text
=
"{Binding PropertyName}"
/>
<
TextBlock
Text
=
"{Binding PropertyValue}"
/>
<
TextBlock
Text
=
"{Binding Comments}"
/>
</
StackPanel
>
</
DataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"PanelBarHeaderTemplate"
ItemsSource
=
"{Binding Items,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemTemplate
=
"{StaticResource PanelBarItemTemplate}"
>
<
TextBlock
Text
=
"{Binding Title}"
/>
</
HierarchicalDataTemplate
>
</
Window.Resources
>
<
Grid
>
<
DockPanel
>
<
DockPanel
DockPanel.Dock
=
"Right"
Width
=
"350"
>
<
Label
/>
</
DockPanel
>
<
DockPanel
DockPanel.Dock
=
"Right"
VerticalAlignment
=
"Bottom"
>
<
telerik:RadPanelBar
ItemsSource
=
"{Binding AccordionItems,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
ItemTemplate
=
"{StaticResource PanelBarHeaderTemplate}"
telerik:StyleManager.Theme
=
"Windows7"
/>
</
DockPanel
>
</
DockPanel
>
</
Grid
>
C# ViewModel
public
class
MainViewModel:ViewModelBase
{
public
MainViewModel()
{
_accordionItems =
new
List<AccoordionHelper>();
AccordionItems =
new
List<AccoordionHelper>();
_accordionItems.Add(
new
AccoordionHelper(
"OffFinalBill"
,
new
AccordionItemsHelper(){ Comments=
"hello"
, PropertyName=
"Off Final 1: "
, PropertyValue=
"12121"
}));
_accordionItems.Add(
new
AccoordionHelper(
"PartFinal"
,
new
AccordionItemsHelper() { Comments =
"hello"
, PropertyName =
"Off Final 1: "
, PropertyValue =
"12121"
}));
AccordionItems = _accordionItems;
}
private
List<AccoordionHelper> _accordionItems =
new
List<AccoordionHelper>();
public
List<AccoordionHelper> AccordionItems
{
get
{
if
(_accordionItems ==
null
)
{
_accordionItems =
new
List<AccoordionHelper>();
}
return
_accordionItems;
}
set
{
_accordionItems = value;
this
.RaisePropertyChanged(
"AccordionItems"
);
}
}
}
public
class
AccoordionHelper:ViewModelBase
{
private
string
_title;
public
string
Title
{
get
{
return
_title;
}
set
{
_title = value;
this
.RaisePropertyChanged(
"Title"
);
}
}
private
AccordionItemsHelper _items;
public
AccordionItemsHelper Items
{
get
{
if
(_items ==
null
)
{
_items =
new
AccordionItemsHelper();
}
return
_items;
}
set
{
_items = value;
this
.RaisePropertyChanged(
"Items"
);
}
}
public
AccoordionHelper(
string
title, AccordionItemsHelper items)
{
Items=items;
Title = title;
}
}
public
class
AccordionItemsHelper
{
public
string
PropertyName {
get
;
set
; }
public
string
PropertyValue {
get
;
set
; }
public
string
Comments {
get
;
set
; }
}