Posted 5 April 2024, 8:31 am EST - Updated 5 April 2024, 8:36 am EST
Gradient tab of PropertyGrid
Posted by: info on 5 April 2024, 8:31 am EST
-
-
Posted 8 April 2024, 8:19 am EST - Updated 8 April 2024, 8:25 am EST
Hi Mikihiro,
Currently, there is no direct way of hiding ‘Gradient’ tab. However, you can achieve the desired behavior by considering the workaround to modify the template of C1BrushEditor, that appears on clicking the drop-down button. This can be done by handling C1PropertyGrid’s PreviewMouseDown event as shown in the following code snippet;
private void PropGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (e.OriginalSource is Rectangle rec) { if (rec.TemplatedParent is C1BrushPicker picker) { var brEdit = picker.Template.FindName("BrushEditor", picker) as C1BrushEditor; brEdit.Loaded += BrEdit_Loaded; } else if (rec.TemplatedParent is C1ToggleButton toggBtn) { var par = toggBtn.TemplatedParent; if (toggBtn.TemplatedParent is C1DropDownButton drpBtn) { if (drpBtn.Content is C1BrushEditor brEdit) { brEdit.Loaded += BrEdit_Loaded; } } } } else if (e.OriginalSource is C1CheckeredBorder chkBorder) { if (chkBorder.TemplatedParent is C1BrushPicker picker) { var brEdit = picker.Template.FindName("BrushEditor", picker) as C1BrushEditor; brEdit.Loaded += BrEdit_Loaded; } } } private void BrEdit_Loaded(object sender, RoutedEventArgs e) { if(sender is C1BrushEditor brushEdit) { var gradTab = brushEdit.Template.FindName("GradientBrushTab", brushEdit) as C1TabItem; if(gradTab != null) { gradTab.Visibility = Visibility.Collapsed; } } }
Kindly refer to the attached sample for full implementation. See PropGridGradient.zip
Otherwise, you can refer to the “Custom Editors” section of the same product sample application, to customize the editor as per your requirement.
Hope this helps you.
Thanks & Regards,
Aastha -
Posted 13 April 2024, 2:03 am EST
Thank you for your help.