i have a radGrid that bind to string with delimiter such as : string: key=value;key=value;....
i bind this string to the grid by converter from string to dictionary and back.
this is the radgrid:
<
telerik:RadGridView
x:Name
=
"radGrid"
Grid.Column
=
"0"
Grid.Row
=
"5"
Grid.ColumnSpan
=
"2"
Margin
=
"10,20,10,10"
NewRowPosition
=
"Top"
ItemsSource="{Binding CurrentParameter.Values,
Mode
=
TwoWay
,
Converter={StaticResource StringToDictConverter}}"
AddingNewDataItem
=
"valuesGrid_AddingNewDataItem"
CanUserInsertRows
=
"True"
IsReadOnly
=
"False"
CanUserDeleteRows
=
"True"
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewSelectColumn
/>
<
telerik:GridViewDataColumn
Header
=
"Key"
DataMemberBinding
=
"{Binding Key}"
Width
=
"*"
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
Header
=
"Value"
DataMemberBinding
=
"{Binding Value}"
Width
=
"*"
> </
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
this is the converter:
public
object
Convert(
object
value,
Type targetType,
object
parameter,
CultureInfo culture
)
{
Dictionary<
string
,
string
> dict =
new
Dictionary<
string
,
string
>();
if
(value !=
null
)
{
string
[] arr = value.ToString().Split(
new
string
[] {
";"
}, StringSplitOptions.RemoveEmptyEntries);
foreach
(
string
s
in
arr)
{
string
[] sArr = s.Split(
new
string
[] {
"="
}, StringSplitOptions.RemoveEmptyEntries);
dict.Add(sArr[0], sArr[1]);
}
}
return
dict;
}
public
object
ConvertBack
(
object
value,
Type targetType,
object
parameter,
CultureInfo culture
)
{
if
(!(value
is
Dictionary<
string
,
string
>))
return
null
;
string
sBack =
""
;
foreach
(KeyValuePair<
string
,
string
> item
in
(Dictionary<
string
,
string
>)value)
{
sBack += item.Key +
"="
+ item.Value +
";"
;
}
return
sBack;
}
the currentParameter Implements INotifyPropertyChanged.
so i want to edit the values in radGrid but it's not possible because the keyValuePair from converter is read only!
what i can do?