Can't get IsEnabled on Item to work

5 posts, 0 answers
  1. Mike
    Mike avatar
    28 posts
    Member since:
    Apr 2013

    Posted 09 Apr 2015 Link to this post

    I've had a standard ComboBox working with this code:

     

    <ComboBox
        x:Name="comboWindow1"
        SelectedValue="{Binding Window1Page}"
        ItemsSource="{Binding listDashData, UpdateSourceTrigger=PropertyChanged}"
        DisplayMemberPath="ddDashDescription"
        SelectedValuePath="ddDashName"
        SelectionChanged="comboWindow1_SelectionChanged">
        <ComboBox.ItemContainerStyle>
            <Style TargetType="{x:Type ComboBoxItem}">
                <Setter Property="IsEnabled" Value="{Binding ddDashEnabled}"/>
            </Style>
        </ComboBox.ItemContainerStyle>
    </ComboBox>

    I switched over to the RadComboBox, thinking I could do almost exactly the same thing. However when I select the drop down, I get no items. If I remove the ContainerStyle then that works a treat.

    I've looked at the various examples in the help, but nothing seems to work.

    Both these code examples fail:

    <UserControl.Resources>
        <Style x:Key="ComboIsEnabledStyle" TargetType="{x:Type tel:RadComboBoxItem}">
            <Setter Property="IsEnabled" Value="{Binding ddDashEnabled}"/>
        </Style>
    </UserControl.Resources>
     
    <tel:RadComboBox
        x:Name="comboWindow2"
        SelectedValue="{Binding Window2Page}"
        ItemsSource="{Binding listDashData, UpdateSourceTrigger=PropertyChanged}"
        DisplayMemberPath="ddDashDescription"
        SelectedValuePath="ddDashName"
        ItemContainerStyle="{StaticResource ComboIsEnabledStyle}"
        SelectionChanged="comboWindow2_SelectionChanged">      
    </tel:RadComboBox>
     
    <tel:RadComboBox
        x:Name="comboWindow1"
        SelectedValue="{Binding Window1Page}"
        ItemsSource="{Binding listDashData, UpdateSourceTrigger=PropertyChanged}"
        DisplayMemberPath="ddDashDescription"
        SelectedValuePath="ddDashName"
        SelectionChanged="comboWindow1_SelectionChanged">
        <tel:RadComboBox.ItemContainerStyle>
            <Style TargetType="{x:Type tel:RadComboBoxItem}">
                <Setter Property="IsEnabled" Value="{Binding ddDashEnabled}"/>
            </Style>
        </tel:RadComboBox.ItemContainerStyle>
    </tel:RadComboBox>

    I amended one of the Telerik ComboBox examples to demonstrate as that does exactly the same thing. Can't attach, so it's available here: ComboBoxCustomFilteringDemo.zip

    I'm really stumped as to what I've missed, as this should really be such a simple thing to do.

    BTW I'm running the latest 2015.1.225 WPF version

  2. Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 14 Apr 2015 Link to this post

    Hello Mike,

    We tested both the provided sample project and the code-snippet with version 2015.1.225, but it seems everything works as expected on our side - the items get disabled. Please, check the attached sample project and let us know if didn't miss something. Is so, please modify it in order to reproduce the observed issue. Thus we could be able to continue our investigation and provide you with a prompt solution if possible. 

    We are looking forward to hearing from you.

    Regards,
    Nasko
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mike
    Mike avatar
    28 posts
    Member since:
    Apr 2013

    Posted 15 Apr 2015 in reply to Nasko Link to this post

    Hi

    Thanks for the demo. This does indeed work fine. I've looked back at the demo I sent you and my main app and the only thing I can see different is that they use implicit themes. 

    I've gone back over the guidance here: http://docs.telerik.com/devtools/wpf/styling-and-appearance/styling-apperance-implicit-styles-overview and applied this to the demo you attached. I have tried both methods of either including the xaml directly with the no-xaml dlls, or including the theme dll along with the no-binary dlls. In both instances I get the combo box failing to drop down properly. I've uploaded the demo you provided with the theme changes (here) and also a quick video of what I see on my side (here).

    I must be doing something pretty fundamentally wrong when I add the theme I would think. 

    This is the path to the XAML I import: C:\Program Files (x86)\Telerik\UI for WPF Q1 2015\Themes.Implicit\WPF40\VisualStudio2013\Themes

    This is the ​path to the binaries I import: C:\Program Files (x86)\Telerik\UI for WPF Q1 2015\Binaries.NoXaml\WPF45

    I also tried the WPF40 folder, as I wasn't 100% sure if using the WPF45 binaries with the WPF40 theme noxaml would work, but I get the same result.

    Thanks, Mike...

  5. Mike
    Mike avatar
    28 posts
    Member since:
    Apr 2013

    Posted 16 Apr 2015 Link to this post

    After looking at a few more examples and forum posts I saw what the problem was.

    I've not included the "BasedOn="{StaticResource RadComboBoxItemStyle}"" as part of the style override. I've just added that in and it's now behaving as it should.

    Thanks for the help.

  6. Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 16 Apr 2015 Link to this post

    Hello Mike,

    I am glad that you've managed to achieve the desired appearance of RadComboBox. If you have any additional questions or concerns regarding Telerik controls, please do not hesitate to contact us.

    Regards,
    Nasko
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready