New to Telerik UI for WPFStart a free 30-day trial

Hiding Add and Remove Buttons in CollectionEditor for WPF

Updated over 6 months ago

Environment

ProductCollectionEditor for WPF

Description

How to hide the Add and Remove buttons in the CollectionEditor control (part of RadPropertyGrid).

Solution

On Loaded of CollectionEditor, set use the ChildrenOfType extension method to get the buttons and set their Visibility to Collapsed.

csharp
	private void CollectionEditor_Loaded(object sender, RoutedEventArgs e)
	{
		var editor = (CollectionEditor)sender;
		var addButton = editor.ChildrenOfType<RadButton>().FirstOrDefault(x => x.Command == CollectionEditorCommands.AddNew);
		if (addButton != null)
		{
			addButton.Visibility = Visibility.Collapsed;
		}
		var removeButton = editor.ChildrenOfType<RadButton>().FirstOrDefault(x => x.Command == CollectionEditorCommands.Delete);
		if (removeButton != null)
		{
			removeButton.Visibility = Visibility.Collapsed;
		}        
	}
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support