Hello,
I have a RadGridView inside a RadExpander as follows:
The SensorDaraBuffer.Targets that the RadGridView is bound to is a ReadOnlyObservableCollection<Target>.
Elsewhere in the same XAML file, I have bound the SelectedItem property of the RadGridView to a DependencyProperty in a UserControl named SensorDataView:
The SelectedTarget DependencyProperty is defined as follows:
My problem is that when the window containing the RadExpander is first displayed (with the RadExpander collapsed) setting the SelectedItem property of the RadGridView does not cause the desired item to be selected. I have tried both setting the SelectedItem property directly on the GridView:
and by setting the SelectedTarget DependencyProperty:
I know that the selection of the desired item is not occurring because I have another control that is bound to the SelectedTarget DependencyProperty and that control does not give any visual indication of the selected target being changed. Also, my OnSelectedTargetChanged event handler in SensorDataView does not get called.
Once I expand the RadExpander via the UI and actually see the RadGridView, the setting of the SelectedItem, regardless of which way I do it, works as expected. I can also then collapse the RadExpander and the setting of the SelectedItem continues to work as expected.
I believe this is an issue with RadGridView because I replaced the RadGridView in the XAML with a ListView as follows:
With the ListView, the setting of the SelectedItem works as expected from the very beginning when the RadExpander is collapsed and continues to work as I expand and collapse the RadExpander.
Does anybody have an idea what may be going here?
Thank you,
-- john
I have a RadGridView inside a RadExpander as follows:
<
telerik:RadExpander
Grid.Row
=
"2"
Grid.Column
=
"0"
IsExpanded
=
"False"
Margin
=
"0,10,0,0"
>
<
telerik:RadExpander.Header
>
<
TextBlock
Text
=
"{Binding ElementName=_this, Path=TargetStatistics.TargetCount, StringFormat=Targets ({0})}"
/>
</
telerik:RadExpander.Header
>
<
telerik:RadGridView
x:Name
=
"targetList"
ItemsSource
=
"{Binding Path=SensorDataBuffer.Targets}"
AutoGenerateColumns
=
"False"
CanUserDeleteRows
=
"False"
CanUserInsertRows
=
"False"
IsReadOnly
=
"True"
IsFilteringAllowed
=
"False"
ScrollViewer.HorizontalScrollBarVisibility
=
"Auto"
ScrollViewer.VerticalScrollBarVisibility
=
"Visible"
RowIndicatorVisibility
=
"Collapsed"
SelectionMode
=
"Single"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"Timestamp"
DataMemberBinding
=
"{Binding Path=Timestamp, StringFormat=HH:mm:ss}"
/>
<
telerik:GridViewDataColumn
Header
=
"Location"
DataMemberBinding
=
"{Binding Path=Location, Converter={StaticResource LocationConverter}}"
/>
<
telerik:GridViewDataColumn
Header
=
"Confidence"
DataMemberBinding
=
"{Binding Path=Confidence, StringFormat=p0}"
/>
<
telerik:GridViewDataColumn
Header
=
"Depth"
DataMemberBinding
=
"{Binding Path=Depth, Converter={StaticResource DistanceConverter}}"
/>
<
telerik:GridViewDataColumn
Header
=
"Detected by"
DataMemberBinding
=
"{Binding Path=TargetDetectType.Enum}"
/>
<
telerik:GridViewDataColumn
Header
=
"User action"
DataMemberBinding
=
"{Binding Converter={StaticResource TargetToUserActionConverter}}"
/>
<
telerik:GridViewDataColumn
Header
=
"Status"
DataMemberBinding
=
"{Binding Converter={StaticResource TargetToCurrentStatusConverter}}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
telerik:RadExpander
>
The SensorDaraBuffer.Targets that the RadGridView is bound to is a ReadOnlyObservableCollection<Target>.
Elsewhere in the same XAML file, I have bound the SelectedItem property of the RadGridView to a DependencyProperty in a UserControl named SensorDataView:
<
local:SensorDataView
x:Name
=
"sensorDataView"
SelectedTarget
=
"{Binding ElementName=targetList, Path=SelectedItem, Mode=TwoWay}"
/>
The SelectedTarget DependencyProperty is defined as follows:
public
static
DependencyProperty SelectedTargetProperty = DependencyProperty.Register(
"SelectedTarget"
,
typeof
(Target),
typeof
(SensorDataView),
new
FrameworkPropertyMetadata(
null
, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedTargetChanged));
My problem is that when the window containing the RadExpander is first displayed (with the RadExpander collapsed) setting the SelectedItem property of the RadGridView does not cause the desired item to be selected. I have tried both setting the SelectedItem property directly on the GridView:
targetList.SelectedItem = target;
and by setting the SelectedTarget DependencyProperty:
sensorDataView.SelectedTarget = target;
I know that the selection of the desired item is not occurring because I have another control that is bound to the SelectedTarget DependencyProperty and that control does not give any visual indication of the selected target being changed. Also, my OnSelectedTargetChanged event handler in SensorDataView does not get called.
Once I expand the RadExpander via the UI and actually see the RadGridView, the setting of the SelectedItem, regardless of which way I do it, works as expected. I can also then collapse the RadExpander and the setting of the SelectedItem continues to work as expected.
I believe this is an issue with RadGridView because I replaced the RadGridView in the XAML with a ListView as follows:
<
ListView
Grid.Row
=
"2"
Grid.Column
=
"0"
Grid.ColumnSpan
=
"4"
x:Name
=
"targetList"
ItemsSource
=
"{Binding Path=SensorDataBuffer.Targets}"
Margin
=
"10,0,0,0"
>
<
ListView.View
>
<
GridView
>
<
GridViewColumn
Header
=
"Timestamp"
DisplayMemberBinding
=
"{Binding Path=Timestamp, StringFormat=HH:mm}"
/>
<
GridViewColumn
Header
=
"Location"
DisplayMemberBinding
=
"{Binding Path=Location, Converter={StaticResource LocationConverter}}"
/>
<
GridViewColumn
Header
=
"Confidence"
DisplayMemberBinding
=
"{Binding Path=Confidence, StringFormat=p0}"
/>
<
GridViewColumn
Header
=
"Depth"
DisplayMemberBinding
=
"{Binding Path=Depth, Converter={StaticResource DistanceConverter}}"
/>
<
GridViewColumn
Header
=
"Detection Type"
DisplayMemberBinding
=
"{Binding Path=TargetDetectType.Enum}"
/>
<
GridViewColumn
Header
=
"Status"
DisplayMemberBinding
=
"{Binding Converter={StaticResource TargetToCurrentStatusConverter}}"
/>
</
GridView
>
</
ListView.View
>
</
ListView
>
With the ListView, the setting of the SelectedItem works as expected from the very beginning when the RadExpander is collapsed and continues to work as I expand and collapse the RadExpander.
Does anybody have an idea what may be going here?
Thank you,
-- john