I'm attempting to control the visibility of a PropertyDefinition
in a Telerik RadPropertyGrid
by binding to the property's Visibility
attribute, but it appears as though the PropertyDefinition
ignores changes to that attribute.
The control's XAML code is below. Note TestVis
.
<Window x:Class="SettingsDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Title="SettingsDialog"
Height="500"
Width="330">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<telerik:RadPropertyGrid
Grid.Row="0"
x:Name="PropertyGrid"
AutoGeneratePropertyDefinitions="False"
Item="{Binding}">
<telerik:RadPropertyGrid.PropertyDefinitions>
<telerik:PropertyDefinition
Binding="{Binding Setting1}"
DisplayName="Property 1"
Description=""Lorem ipsum dolor sit amet"
/>
<telerik:PropertyDefinition
Binding="{Binding Setting2}"
Visibility="{Binding TestVis}"
DisplayName="Property 2"
Description=""Lorem ipsum dolor sit amet"
/>
</telerik:RadPropertyGrid.PropertyDefinitions>
</telerik:RadPropertyGrid>
</Grid>
</Window>
The code-behind for this dialog is below.
using System.Windows;
public partial class SettingsDialog : Window
{
private Visibility _TestVis;
public Visibility TestVis
{
get { return _TestVis; }
set
{
this._TestVis = value;
NotifyPropertyChanged( "TestVis" );
}
}
public bool Setting1 = { get; set; }
public bool Setting2 = { get; set; }
public SettingsDialog()
{
Setting1 = true;
Setting2 = true;
TestVis = Visibility.Collapsed;
InitializeComponent();
}
}
I would expect that this would cause "Property 2" to not be displayed, but there it is. What am I doing wrong?