I have a ObservableCollection<Item> collection which I am using as a grid items source. The Item class objects have a property whose value dictates how the grid row for that object should look like. In most cases, rows will be same, with textboxes and checkboxes. However, for a few certain values, the row should only display a dropdown/combobox in the first cell and gray out the rest of the cells. The dropdown should be populated somehow with a collection that is retrieved while the control is loaded and the selected value should be the value of the Item.ListName property.Is there any way of achieving this, like using DataTemplate/ContentControl/IValueConverter implementations?Thanks
Quick & dirty way to do that, but not necessarily the best:
Bool to visibility converter:
Public
Class BoolToVisibilityConverter
Implements IValueConverter
End Class
Class
BoolToVisibilityConverter
Implements
IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements
System.Windows.Data.IValueConverter.Convert
Return IIf(CType(value, Boolean
), Visibility.Visible, Visibility.Collapsed)
End
Function
System.Windows.Data.IValueConverter.ConvertBack
Return (CType
(value, Visibility) = Visibility.Visible)