Hello,
I don't know if this a bug or a feature but I have a gridview where I am allowing the user to select/unselect a row. When the user selects a row, SelectedItem bound to the ViewModel is set properly and the event SelectionChanged is triggered. But when the user clicks to unselect and clicks in the same cell that she clicked to select, the event is not triggered and neither is SelectedItem changed. If the user clicks inside a different cell on the same row everything works perfectly.
Why do I get this behaviour? Is there anything wrong or just me not understanding the GridView?
Below is my GridView in XAML.
Regards, Clas Ericson
I don't know if this a bug or a feature but I have a gridview where I am allowing the user to select/unselect a row. When the user selects a row, SelectedItem bound to the ViewModel is set properly and the event SelectionChanged is triggered. But when the user clicks to unselect and clicks in the same cell that she clicked to select, the event is not triggered and neither is SelectedItem changed. If the user clicks inside a different cell on the same row everything works perfectly.
Why do I get this behaviour? Is there anything wrong or just me not understanding the GridView?
Below is my GridView in XAML.
Regards, Clas Ericson
<
telerik:RadGridView
x:Name
=
"DataGrid"
Margin
=
"0,0,5,0"
GridLinesVisibility
=
"None"
CanUserFreezeColumns
=
"False"
BorderBrush
=
"White"
BorderThickness
=
"0"
ShowGroupPanel
=
"False"
AutoGenerateColumns
=
"False"
HeaderRowStyle
=
"{StaticResource GridViewHeaderRowStyle1}"
RowStyle
=
"{StaticResource GridViewRowStyle1}"
Background
=
"{StaticResource GridViewRowBrush}"
AlternateRowBackground
=
"{StaticResource GridViewAlternatingRowBrush}"
AlternationCount
=
"2"
Foreground
=
"{StaticResource CountyShapeColor}"
GroupPanelForeground
=
"{StaticResource CountyShapeColor}"
IsFilteringAllowed
=
"False"
CanUserReorderColumns
=
"False"
CanUserResizeColumns
=
"False"
GroupPanelBackground
=
"Transparent"
HorizontalGridLinesBrush
=
"Transparent"
VerticalGridLinesBrush
=
"White"
VisibleRowsHeight
=
"0"
RowHeight
=
"8"
FontSize
=
"10"
RowIndicatorVisibility
=
"Collapsed"
ItemsSource
=
"{Binding SelectList}"
CanUserSelect
=
"True"
SelectionMode
=
"Multiple"
SelectedItem
=
"{Binding SelectedItem,Mode=TwoWay}"
SelectionChanged
=
"DataGrid_SelectionChanged"
SelectionUnit
=
"FullRow"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
IsSortable
=
"False"
IsReadOnly
=
"True"
Width
=
"*"
HeaderCellStyle
=
"{StaticResource myGridHeaderStyleLeft}"
CellStyle
=
"{StaticResource GridViewCellStyleLeft}"
>
<
telerik:GridViewDataColumn.Header
>
<
Grid
Height
=
"39"
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"*"
/>
<
ColumnDefinition
Width
=
"*"
/>
<
ColumnDefinition
Width
=
"75"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Margin
=
"10,2,2,2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
BuildingInformation
}"
Grid.ColumnSpan
=
"3"
/>
<
TextBlock
x:Name
=
"tbPlaceRealEstate"
Margin
=
"10,2,2,2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
RealEstate
}"
Grid.Row
=
"1"
MouseLeftButtonDown
=
"tbGridMouseLeftButtonDown"
MouseEnter
=
"TextBlock_MouseEnter"
MouseLeave
=
"TextBlock_MouseLeave"
/>
<
TextBlock
x:Name
=
"tbPlaceBuilding"
Margin
=
"2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
Building
}"
Grid.Row
=
"1"
Grid.Column
=
"1"
MouseLeftButtonDown
=
"tbGridMouseLeftButtonDown"
MouseEnter
=
"TextBlock_MouseEnter"
MouseLeave
=
"TextBlock_MouseLeave"
/>
<
TextBlock
x:Name
=
"tbPlaceArea"
TextAlignment
=
"Right"
Margin
=
"2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
Area
}"
Grid.Row
=
"1"
Grid.Column
=
"2"
MouseLeftButtonDown
=
"tbGridMouseLeftButtonDown"
MouseEnter
=
"TextBlock_MouseEnter"
MouseLeave
=
"TextBlock_MouseLeave"
/>
</
Grid
>
</
telerik:GridViewDataColumn.Header
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"*"
/>
<
ColumnDefinition
Width
=
"*"
/>
<
ColumnDefinition
Width
=
"75"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Margin
=
"10,2,2,2"
Text
=
"{Binding parentObjectName}"
Grid.Column
=
"0"
TextAlignment
=
"Left"
/>
<
TextBlock
Margin
=
"2"
Text
=
"{Binding objectName}"
Grid.Column
=
"1"
TextAlignment
=
"Left"
/>
<
TextBlock
Margin
=
"2"
Text
=
"{Binding Path=totalArea}"
Grid.Column
=
"2"
TextAlignment
=
"Right"
/>
</
Grid
>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
IsSortable
=
"False"
IsReadOnly
=
"True"
Width
=
"150"
HeaderCellStyle
=
"{StaticResource myGridHeaderStyle}"
CellStyle
=
"{StaticResource GridViewCellStyle}"
>
<
telerik:GridViewDataColumn.Header
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"75"
/>
<
ColumnDefinition
Width
=
"75"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Margin
=
"2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
Energy
}"
Grid.ColumnSpan
=
"2"
/>
<
TextBlock
x:Name
=
"tbEnergyKWh"
Margin
=
"2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
UnitConsumptionArea
}"
Grid.Row
=
"1"
MouseLeftButtonDown
=
"tbGridMouseLeftButtonDown"
MouseEnter
=
"TextBlock_MouseEnter"
MouseLeave
=
"TextBlock_MouseLeave"
/>
<
TextBlock
x:Name
=
"tbEnergyDiff"
Margin
=
"2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
DifferencePercent
}"
Grid.Row
=
"1"
Grid.Column
=
"1"
TextAlignment
=
"Right"
MouseLeftButtonDown
=
"tbGridMouseLeftButtonDown"
MouseEnter
=
"TextBlock_MouseEnter"
MouseLeave
=
"TextBlock_MouseLeave"
/>
</
Grid
>
</
telerik:GridViewDataColumn.Header
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"75"
/>
<
ColumnDefinition
Width
=
"75"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Margin
=
"2"
Text
=
"{Binding consumption, StringFormat=\{0:N2\}}"
Grid.Column
=
"0"
/>
<
TextBlock
Margin
=
"2"
Text
=
"{Binding StringFormat=\{0:P\}, Path=consumptionDifference}"
Grid.Column
=
"1"
TextAlignment
=
"Right"
/>
</
Grid
>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
IsSortable
=
"False"
IsReadOnly
=
"True"
Width
=
"150"
HeaderCellStyle
=
"{StaticResource myGridHeaderStyle}"
CellStyle
=
"{StaticResource GridViewCellStyle}"
>
<
telerik:GridViewDataColumn.Header
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"75"
/>
<
ColumnDefinition
Width
=
"75"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Margin
=
"2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
Economy
}"
Grid.ColumnSpan
=
"2"
/>
<
TextBlock
x:Name
=
"tbEconomyCost"
Margin
=
"2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
UnitSEKArea
}"
Grid.Row
=
"1"
MouseLeftButtonDown
=
"tbGridMouseLeftButtonDown"
MouseEnter
=
"TextBlock_MouseEnter"
MouseLeave
=
"TextBlock_MouseLeave"
/>
<
TextBlock
x:Name
=
"tbEconomyDiff"
Margin
=
"2"
Text="{Binding
Path
=
DynamicTranslatedString
,
Source={StaticResource ApplicationResources},
Mode
=
OneWay
,
Converter={StaticResource ApplicationResources},
ConverterParameter
=
DifferencePercent
}"
Grid.Row
=
"1"
Grid.Column
=
"1"
TextAlignment
=
"Right"
MouseLeftButtonDown
=
"tbGridMouseLeftButtonDown"
MouseEnter
=
"TextBlock_MouseEnter"
MouseLeave
=
"TextBlock_MouseLeave"
/>
</
Grid
>
</
telerik:GridViewDataColumn.Header
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"75"
/>
<
ColumnDefinition
Width
=
"75"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Margin
=
"2"
Text
=
"{Binding cost, StringFormat=\{0:N2\}}"
Grid.Column
=
"0"
/>
<
TextBlock
Margin
=
"2"
Text
=
"{Binding StringFormat=\{0:P\}, Path=costDifference}"
Grid.Column
=
"1"
TextAlignment
=
"Right"
/>
</
Grid
>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>