HOW CAN I SET VISIBILITY OF A GRID USING WPF

Aaron Douglas

Total Post:20

Points:140
Posted by  Aaron Douglas
C# 
C#
 1611  View(s)
Ratings:
Rate this:

I have a home page and in that i have 2 grids, one internal and another external. In the parent grid i have a data-grid.when am clicking on the row of the datagrid i need to make visible the child grid which contains the controls that is binded to the clicked row values.

  1. Brad Pitt

    Post:61

    Points:429
    Re: How can I set visibility of a Grid using WPF

    <Grid Grid.Row="1" Visibility={Binding SelectedEmployee, Converter={StaticResource NotNullToVisibilityConverter}} ...>

    Here is the converter code:

    public class NotNullToVisibilityConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                if (value == null)
                    return Visibility.Hidden; // or Visibility.Collapsed
     
                return Visibility.Visible;
            }
     
            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!