or
<
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
>
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
; }
}
private
void
editCabinetForm_AutoGeneratingField(
object
sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
{
if
(e.PropertyName ==
"CabinetName"
)
{
e.DataField.Label =
"Cabinet Name"
;
}
else
if
(e.PropertyName ==
"BriefDescription"
)
{
e.DataField.Label =
"Brief Description"
;
}
else
if
(e.PropertyName ==
"Comments"
)
{
RadRichTextBox commentsBox =
new
RadRichTextBox();
//commentsBox.SetBinding(???, new Binding("Comments"));
e.DataField.Content = commentsBox;
e.DataField.Label =
"Comments"
;
}
else
{
e.Cancel =
true
;
}
}
dBVideoArchiveDataSetArchiveTableTableAdapter.Update(dBVideoArchiveDataSet.ArchiveTable);
dBVideoArchiveDataSet.AcceptChanges();
radGridView1.Rebind();
-populate table (set binding in row_loaded)
-set background on viewmodel
-converter not called.
-clear table
-populate table (again create binding)
-set background, then it is called.
While in debug, when I checked PropertChanged.Target, in first run it is System.ComponentModel.PropertyChangedEventManager (doesnt work),
and in the second run, it is Telerik.Windows.Data.WeakEvent.WeakListener<System.ComponentModel.PropertyChangedEventArgs>.
Telerik version : 2011.1.411.40
MultiBinding multiBindingBackground = new MultiBinding();
multiBindingBackground.Converter = cellColorConverter;
Binding background = new Binding("Background");
background.Source = row.Item;
background.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
//background.Mode = BindingMode.TwoWay;
multiBindingBackground.Bindings.Add(background);
multiBindingBackground.Bindings.Add(rcBinding);
Binding isBackgroundForBackground = new Binding();
isBackgroundForBackground.Source = true;
multiBindingBackground.Bindings.Add(isBackgroundForBackground);
multiBindingBackground.Bindings.Add(new Binding());
cellBase.SetBinding(GridViewCellBase.BackgroundProperty, multiBindingBackground);