Hi,
I'm having problems with binding my items within a gridview controltemplate. I've already followed the WPF examples of it (GridView Examples - Appearence - Custom Row Layout), but whatever I try, binding isn't working when the RowStyle/ControlTemplate is active.
Below a simplified code snippet from the example, but with my own binding names:
You see the bindings to Data1, Data2, Data3, but as soon as I run it, those field stay empty, see screenshot 1
However, when I remove the
I've already tried binding with Path=, or CurrentItem.Data1 and several other options, but none of it works, while it works in de example.
I'm problably missing something, but if I compare my code with the example, I don't see any difference in binding, so any help would be appreciated.
Thanks in advance
I'm having problems with binding my items within a gridview controltemplate. I've already followed the WPF examples of it (GridView Examples - Appearence - Custom Row Layout), but whatever I try, binding isn't working when the RowStyle/ControlTemplate is active.
Below a simplified code snippet from the example, but with my own binding names:
<
Grid
>
<
Grid.Resources
>
<
ControlTemplate
x:Key
=
"MyCustomRowTemplate"
TargetType
=
"telerik:GridViewRow"
>
<
Border
x:Name
=
"rowsContainer"
BorderThickness
=
"0,0,0,1"
>
<
Grid
Width
=
"Auto"
HorizontalAlignment
=
"Stretch"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"20"
/>
<
RowDefinition
Height
=
"20"
/>
<
RowDefinition
Height
=
"20"
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"Auto"
/>
<
ColumnDefinition
Width
=
"150"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Text
=
"Data1: "
Margin
=
"5,0,0,0"
FontWeight
=
"Bold"
Grid.Row
=
"0"
Grid.Column
=
"0"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Left"
/>
<
TextBlock
Text
=
"{Binding Data1}"
Margin
=
"5,0,0,0"
Grid.Row
=
"0"
Grid.Column
=
"1"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Left"
/>
<
TextBlock
Text
=
"Data2: "
Margin
=
"5,0,0,0"
FontWeight
=
"Bold"
Grid.Row
=
"1"
Grid.Column
=
"0"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
/>
<
TextBlock
Text
=
"{Binding Data2}"
Margin
=
"5,0,0,0"
Grid.Row
=
"1"
Grid.Column
=
"1"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Left"
/>
<
TextBlock
Text
=
"Data3: "
Margin
=
"5,0,0,0"
FontWeight
=
"Bold"
Grid.Row
=
"2"
Grid.Column
=
"0"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
/>
<
TextBlock
Text
=
"{Binding Data3}"
Margin
=
"5,0,0,0"
Grid.Row
=
"2"
Grid.Column
=
"1"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Left"
/>
</
Grid
>
</
Border
>
</
ControlTemplate
>
<
Style
x:Key
=
"rowStyle"
TargetType
=
"telerik:GridViewRow"
>
<
Setter
Property
=
"Template"
Value
=
"{StaticResource MyCustomRowTemplate}"
/>
</
Style
>
</
Grid.Resources
>
<
telerik:RadGridView
RowStyle
=
"{StaticResource rowStyle}"
ItemsSource
=
"{Binding Contacts}"
ShowGroupPanel
=
"False"
BorderThickness
=
"0"
IsFilteringAllowed
=
"False"
AutoGenerateColumns
=
"False"
CanUserFreezeColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"Data1"
DataMemberBinding
=
"{Binding Data1}"
/>
<
telerik:GridViewDataColumn
Header
=
"Data2"
DataMemberBinding
=
"{Binding Data2}"
/>
<
telerik:GridViewDataColumn
Header
=
"Data3"
DataMemberBinding
=
"{Binding Data3}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
Grid
>
You see the bindings to Data1, Data2, Data3, but as soon as I run it, those field stay empty, see screenshot 1
However, when I remove the
RowStyle="{StaticResource rowStyle}"
in my RadGridView then the Data is displayed correctly in the row, see screenshot 2I've already tried binding with Path=, or CurrentItem.Data1 and several other options, but none of it works, while it works in de example.
I'm problably missing something, but if I compare my code with the example, I don't see any difference in binding, so any help would be appreciated.
Thanks in advance