Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Enabling or disabling a property in PropertyGrid based on another property's value

$
0
0
Hi, this is an feature asked on the PropertyGrid : https://wpftoolkit.codeplex.com/workitem/18507
Please vote for it.

In the meantime, there could be a workaround. When a value of a propertyItem changes in the PropertyGrid, you could change the IsEnabled property of another PropertyItem. Here's how with the PropertyValueChanged callback from the PropertyGrid.
private void PropertyGrid_PropertyValueChanged( object sender, Xceed.Wpf.Toolkit.PropertyGrid.PropertyValueChangedEventArgs e )
    {
      PropertyItem item = e.OriginalSource as PropertyItem;

      if( (item != null) && (item.DisplayName == "HasText" ) )
      {
        List<PropertyItem> propertyList = PropertyGrid.Properties.Cast<PropertyItem>().ToList();
        if( propertyList != null )
        {
          int index = propertyList.FindIndex( x => x.DisplayName == "Text" );
          if( index >= 0 )
          {
            ( ( PropertyItem )PropertyGrid.Properties[ index ] ).IsEnabled = ( bool )e.NewValue;
          }
        }
      }
    }

Viewing all articles
Browse latest Browse all 4964

Trending Articles