This question is locked. New answers and comments are not allowed.
Hi guys,
This has been eluding me for some time so I have decided to pose my scenario to the forum. I have two objects as follows:
I have two grids declared as follows:
My converter is as follows:
The problem is that the first parameter (value as Object) is of type ClassB and not ClassA. Because of this I am unable to set the visibility of the FieldB3 column in the child grid based on a field/column value in the parent row (ClassA). Can someone point me in the right direction?
Thanks in advance (and apologies for the wordy post).
This has been eluding me for some time so I have decided to pose my scenario to the forum. I have two objects as follows:
Public Class A
Public Property FieldA1 As String
Public Property FieldA2 As String
Public Property FieldA3 As IEnumerable(Of B)
End Class
Public Class B
Public Property FieldB1 As String
Public Property FieldB2 As String
Public Property FieldB3 As String
End Class
I have two grids declared as follows:
<
telerik:RadGridView
x:Name
=
"GridA"
AutoGenerateColumns
=
"False"
RowIndicatorVisibility
=
"Collapsed"
RowDetailsVisibilityMode
=
"VisibleWhenSelected"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FieldA1}"
Header
=
"Field A1"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FieldA2}"
Header
=
"Field A2"
/>
</
telerik:RadGridView.Columns
>
<
telerik:RadGridView.RowDetailsTemplate
>
<
DataTemplate
>
<
telerik:RadGridView
x:Name
=
"GridB"
ItemsSource
=
"{Binding FieldA3}"
AutoGenerateColumns
=
"False"
RowIndicatorVisibility
=
"Visible"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FieldB1}"
Header
=
"Field B1"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FieldB2}"
Header
=
"Field B2"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FieldB3}"
Header
=
"Field B3"
Visibility={Binding Converter={StaticResource VisibilityConverter}}/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
DataTemplate
>
</
telerik:RadGridView.RowDetailsTemplate
>
</
telerik:RadGridView
>
My converter is as follows:
Imports System.Windows.Data
Namespace Converters
Public Class VisibilityConverter
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Dim _convertedValue As Visibility
'code not implemented yet
Return _convertedValue
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
'not implemented since this is a one-way binding
Throw New NotImplementedException
End Function
End Class
End Namespace
The problem is that the first parameter (value as Object) is of type ClassB and not ClassA. Because of this I am unable to set the visibility of the FieldB3 column in the child grid based on a field/column value in the parent row (ClassA). Can someone point me in the right direction?
Thanks in advance (and apologies for the wordy post).