Everything Is Disabled After Modal

2 posts, 0 answers
  1. Josh
    Josh avatar
    22 posts
    Member since:
    Jun 2012

    Posted 12 Sep 2011 Link to this post

    I have a RadPanelBar with a custom ItemTemplate and custom HierarchicalDataTemplate. I have the IsEnabled property hooked up through the ContainerBindingCollection.

    If I do anything that causes a modal to popup, like using the RadBusyIndicator or showing a silverlight ChildWindow, the screen goes gray, and everything in the RadPanelBar gets disabled. I can set a breakpoint on the setter of IsEnabled and see that when the modal pops up, the setter is getting called with 'false' being set. When the modal goes away, the setter is never called again setting it back to true. The panel bar then stays disabled.

    How can I fix this?

    I don't want to have to manually set them back to enabled. 

    I'm using controls version 2011.1.0411.1040

    Here is the code:

    <UserControl x:Class="TelerikPanelTest.MainPage"
        mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400">
         
        <UserControl.Resources>
            <telerik:ContainerBindingCollection x:Key="BindingsCollection">
                <telerik:ContainerBinding PropertyName="IsExpanded" Binding="{Binding IsExpanded, Mode=TwoWay}" />
                <telerik:ContainerBinding PropertyName="IsEnabled" Binding="{Binding IsEnabled, Mode=TwoWay}" />
            </telerik:ContainerBindingCollection>
        </UserControl.Resources>
     
        <Grid x:Name="LayoutRoot" Background="White">
            <StackPanel>
     
                <telerik:RadPanelBar ItemsSource="{Binding PanelBarItemData}">
                    <telerik:RadPanelBar.ItemTemplate>
                        <telerik:HierarchicalDataTemplate ItemsSource="{Binding Items}" telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}">
                            <TextBlock Text="{Binding HeaderText, Mode=TwoWay}" />
                             
                            <telerik:HierarchicalDataTemplate.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TextBox />
                                        <TextBlock Text="{Binding}" />
                                    </StackPanel>
                                </DataTemplate>
                            </telerik:HierarchicalDataTemplate.ItemTemplate>
                        </telerik:HierarchicalDataTemplate>
                    </telerik:RadPanelBar.ItemTemplate>
                </telerik:RadPanelBar>
     
                <Button Content="Click Me" Click="Button_Click" />
     
            </StackPanel>
        </Grid>
    </UserControl>


    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
     
    namespace TelerikPanelTest
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
                DataContext = new MainPageViewModel();
            }
     
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                var modal = new Modal();
                modal.Show();
            }
        }
    }


    using System;
    using System.Collections.ObjectModel;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
     
    namespace TelerikPanelTest
    {
        public class MainPageViewModel
        {
            private readonly ObservableCollection<PanelBarItemData> panelBarItemData = new ObservableCollection<PanelBarItemData>();
     
            public ObservableCollection<PanelBarItemData> PanelBarItemData
            {
                get { return panelBarItemData; }
            }
     
            public MainPageViewModel()
            {
                panelBarItemData.Add(new PanelBarItemData
                {
                    IsEnabled = true,
                    HeaderText = "Header Text",
                });
            }
        }
    }


    using System;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
     
    namespace TelerikPanelTest
    {
        public class PanelBarItemData : INotifyPropertyChanged
        {
            private bool isEnabled;
            private bool isExpanded = true;
            private string headerText;
            private readonly ObservableCollection<string> items = new ObservableCollection<string>();
     
            public bool IsEnabled
            {
                get { return isEnabled; }
                set
                {
                    isEnabled = value;
                    RaisePropertyChanged("IsEnabled");
                }
            }
     
            public bool IsExpanded
            {
                get { return isExpanded; }
                set
                {
                    isExpanded = value;
                    RaisePropertyChanged("IsExpanded");
                }
            }
     
            public string HeaderText
            {
                get { return headerText; }
                set
                {
                    headerText = value;
                    RaisePropertyChanged("HeaderText");
                }
            }
     
            public ObservableCollection<string> Items
            {
                get { return items; }
            }
     
            public event PropertyChangedEventHandler PropertyChanged;
     
            public PanelBarItemData()
            {
                items.Add("one");
                items.Add("two");
            }
     
            public void RaisePropertyChanged(string propertyName)
            {
                if(PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
        }
    }

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 15 Sep 2011 Link to this post

    Hello Josh,

    It seems that this is a known issue - please have a look at this thread. Basically when you set the IsEnabled property of any ContentControl to false, its children will also be disabled. However, setting the CantentControl IsEnabled property to True won't affect its children enabled state. Both the ChildWindow and the RadBusyIndicator inherit from a ContentControl and this is why this issue can be reproduced with both.

    As a workaround you can manually control the IsEnabled business properties or you can use the RadWindow control instead.

    Best wishes,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top