IsEnabled not working for ComboBox in PropertyGrid

3 posts, 0 answers
  1. Georg
    Georg avatar
    15 posts
    Member since:
    Nov 2007

    Posted 11 Feb Link to this post

    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. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2131 posts

    Posted 14 Feb Link to this post

    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.
  3. Georg
    Georg avatar
    15 posts
    Member since:
    Nov 2007

    Posted 14 Feb Link to this post

    Thanks Martin. The "border" solution worked perfectly.

    Georg

     

Back to Top