This is a migrated thread and some comments may be shown as answers.

IsEnabled not working for ComboBox in PropertyGrid

2 Answers 813 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Georg
Top achievements
Rank 1
Veteran
Georg asked on 11 Feb 2019, 03:18 PM

The example below has a RadComboBox inside a RadPropertyGrid, with a Checkbox controlling the IsEnabled property of the RadComboBox. However, setting IsEnabled=false doesn't do anything. The same example works fine if I use a regular Grid instead of a RadPropertyGrid though.

 

<Window x:Class="DisableComboBox.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:DisableComboBox"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        mc:Ignorable="d"
        Title="MainWindow" Height="100" Width="300">
    <telerik:RadPropertyGrid x:Name="PropertyGrid"
                                 Item="{Binding}"
                                 AutoGeneratePropertyDefinitions="False"
                                 DescriptionPanelVisibility="Collapsed"
                                 SearchBoxVisibility="Collapsed"
                                 SortAndGroupButtonsVisibility="Collapsed"
                                 FieldIndicatorVisibility="Collapsed"
                                 LabelColumnWidth="100">

        <telerik:RadPropertyGrid.PropertyDefinitions>
            <telerik:PropertyDefinition DisplayName="Checkbox" OrderIndex="1">
                <telerik:PropertyDefinition.EditorTemplate>
                    <DataTemplate>
                        <CheckBox
                            VerticalAlignment="Center"
                            VerticalContentAlignment="Center"
                            IsChecked="{Binding ComboBoxIsEnabled}">
                        </CheckBox>
                    </DataTemplate>
                </telerik:PropertyDefinition.EditorTemplate>
            </telerik:PropertyDefinition>
            <telerik:PropertyDefinition DisplayName="Country" OrderIndex="2">
                <telerik:PropertyDefinition.EditorTemplate>
                    <DataTemplate>
                        <telerik:RadComboBox
                            SelectedItem="{Binding CurrentCountry}"
                            IsEditable="False"
                            IsEnabled="{Binding ComboBoxIsEnabled}"
                            ItemsSource="{Binding Countries}">
                        </telerik:RadComboBox>
                    </DataTemplate>
                </telerik:PropertyDefinition.EditorTemplate>
            </telerik:PropertyDefinition>
        </telerik:RadPropertyGrid.PropertyDefinitions>
    </telerik:RadPropertyGrid>
</Window>

 

 

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 14 Feb 2019, 09:57 AM
Hello Georg,

The IsEnabled property doesn't work because the RadPropertyGrid control manually sets the property in code. To avoid this and achieve your requirement you can try the following approaches:
  • Use the IsReadOnly property of the PropertyDefinition instead of the IsEnabled of the RadComboBox.
  • Use the IsHitTestVisible property of the RadComboBox instead of IsEnabled.
  • Wrap the RadComboBox in another element. For example, a Border. This way the internal logic of the RadPropertyGrid control won't find the RadComboBox and won't maintain its IsEnabled.
    <telerik:PropertyDefinition.EditorTemplate>
        <DataTemplate>
            <Border>
                <telerik:RadComboBox SelectedItem="{Binding CurrentCountry}"                               
                                     IsEditable="False" IsEnabled="False"
                                     ItemsSource="{Binding Countries}"/>
            </Border>
        </DataTemplate>
    </telerik:PropertyDefinition.EditorTemplate>

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Georg
Top achievements
Rank 1
Veteran
answered on 14 Feb 2019, 01:52 PM

Thanks Martin. The "border" solution worked perfectly.

Georg

 

Tags
ComboBox
Asked by
Georg
Top achievements
Rank 1
Veteran
Answers by
Martin Ivanov
Telerik team
Georg
Top achievements
Rank 1
Veteran
Share this question
or