Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • In my app at startup, I set the MainWindow.IsEnabled to false.
                                    The BarManager MainMenu and toolbar Bar all look disabled as expected as does the NavBarControl.

                                    After some initialization, I set MainWindow.IsEnabled to true.
                                    Everything then becomes enabled except for the MainMenu and toolbar Bar. Setting IsEnabled=true on these is a workaround but I expected them to inherit the IsEnabled setting. Note that the NavBarControl does inherit correctly.

                                    A quick look at the source code shows this line for the NavBarControl
                                    IsEnabledProperty.OverrideMetadata(typeof(NavBarControl), new FrameworkPropertyMetadata(true, OnIsEnabledChanged));

                                    Should something similar be in place for the BarManager and associated controls?

                                    Steps to Reproduce:

                                    using System;

                                    using System.Collections.Generic;

                                    using System.Linq;

                                    using System.Text;

                                    using System.Windows;

                                    using System.Windows.Controls;

                                    using System.Windows.Data;

                                    using System.Windows.Documents;

                                    using System.Windows.Input;

                                    using System.Windows.Media;

                                    using System.Windows.Media.Imaging;

                                    using System.Windows.Navigation;

                                    using System.Windows.Shapes;

                                    using System.Diagnostics;

                                    namespace WpfApplication38 {

                                        /// <summary>

                                        /// Interaction logic for Window1.xaml

                                        /// </summary>

                                        public partial class Window1 : Window {

                                            public Window1() {

                                                InitializeComponent();

                                            }

                                            private void Button_Click(object sender, RoutedEventArgs e) {

                                                grid.IsEnabled = !grid.IsEnabled;

                                            }

                                        }

                                        public class MyButtonInfo : FrameworkContentElement {

                                            public MyButtonInfo() {

                                                IsEnabledChanged += new DependencyPropertyChangedEventHandler(OnIsEnabledChanged);

                                            }

                                            void OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) {

                                                Trace.WriteLine("IsEnabled = " + IsEnabled.ToString());

                                            }

                                        }

                                        public class MyItemsControl : ItemsControl

                                              {

                                                   static MyItemsControl()

                                                   {

                                                        IsEnabledProperty.OverrideMetadata(typeof(MyItemsControl), new FrameworkPropertyMetadata(true, OnIsEnabledChanged));

                                                   }

                                             protected override bool IsItemItsOwnContainerOverride(object item) {

                                                return false;

                                            }

                                            protected override DependencyObject GetContainerForItemOverride() {

                                                return new Button();

                                            }

                                            protected override void PrepareContainerForItemOverride(DependencyObject element, object item) {

                                                Button btn = element as Button;

                                                btn.Content = ((MyButtonInfo)item).Name;

                                            }

                                              static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {

                                                   ((MyItemsControl)d).OnIsEnabledChanged();

                                              }

                                              void OnIsEnabledChanged() {

                                                   foreach(FrameworkContentElement item in Items)

                                                        item.CoerceValue(IsEnabledProperty);

                                             }

                                        }

                                    }

                                0

                                We'll review this issue, and will answer ASAP. Thank you for the report.

                                Thank you, Marina

                                0

                                Hello,

                                We have reviewed this issue, and come to the conclusion that this is a MS bug. Our Bar class is the FrameworkContentElement descendant. However, the IsEnabledChanged event is raised only once when an item is added to the container. We belive that this is an incorrect behavior. I've attached a sample that illustrates that the same behavior can be reproduced with the standard controls. When I add the MyButtonInfo to the ItemsControl, the IsEnabledChanged event is raised, but when I changed the IsEnabled property for the parent, the IsEnabledChanged event isn't raised. We'll post this issue to MS.

                                Thank you, Marina

                                B146376.zip
                                0

                                Well maybe there is an MS bug and maybe it isn't.
                                (I have a sneaking suspicion that this is something to do with logicaltree vs visualtree)

                                1) Your sample app still toggles the IsEnabled state even if the event isn't fired. My app's menu and toolbar stay permanently disabled so I'm not quite sure they are comparable.

                                2) As I mentioned originally, you seem to have added code specifically to NavBarControl to coerce the IsEnabled on the NavBarGroups and this all works fine. In fact, I just modified your sample app to do the same thing that NavBarControl does and now it fires the event on each change as I think you were expecting.

                                3) Looking in Reflector, IsEnabled (and IsHitTestVisible) seem to have special treatment - See the CoerceIsEnabled static method on UIElement for example and there are other instances of 'parent' controls coercing values onto their contained 'children'

                                0

                                Hello,

                                We'll update this issue when we get a feedback from the MS. The button is Enabled/Disabled because it is placed in a visual tree. Our Bar element isn't placed in a visual tree, because we place a BarControl there. The BarControl's Enabled property depends on the Bar's Enabled property. However, the Enabled property isn't changed for the Bar, and as a result the BarControl works incorrectly, too. We hope that MS fixes this issue. Please wait a little, we'll give a feedback ASAP.

                                Thank you, Marina

                                0

                                Hello,

                                We have decided to change the current behavior on our end, and not to wait for a MS resolution. The next release will not have this inconsistency.

                                Thank you, Marina

                                You must  log in  or  register  to leave an answer

                                Is your intention to post an answer to your own question?

                                • If so, then proceed.
                                • If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
                                • If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Your Privacy - Legal Statements

                                Copyright © 1998-2013 Developer Express Inc.
                                ALL RIGHTS RESERVED
                                All trademarks or registered trademarks
                                are property of their respective owners