In our RadGridView, we have a RowDetailsTemplate which we only wish to show if the bound property "Messages" has a value. The DataTemplate looks like this:
<TelerikGrid:RadGridView.RowDetailsTemplate> |
<DataTemplate> |
<TextBlock Text="{Binding Messages}" Visibility="{Binding Text,RelativeSource={RelativeSource Self},Converter={StaticResource visibleWhenNonEmptyConverter}}"/> |
</DataTemplate> |
</TelerikGrid:RadGridView.RowDetailsTemplate> |
public class VisibleWhenNonEmptyConverter : IValueConverter |
{ |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
{ |
if (value != null && !"".Equals(value)) |
{ |
return Visibility.Visible; |
} |
return Visibility.Collapsed; |
} |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
{ |
throw new NotImplementedException(); |
} |
} |
Is there a better way to implement this? The Messages property gets updated in the background and it implements INotifyPropertyChanged, so when it changes, the row details would need to become visible again.