注意:匿名事件处理函数

 

if (button != null && button.m_defaultMenuItem != menuItem)
            {
      

               button.m_defaultMenuItem.IsEnabledChanged += delegate(object o, DependencyPropertyChangedEventArgs args)
                {
                    MenuItem currentMenu = o as MenuItem;
                     contentControl.IsEnabled = (bool)args.NewValue;
                };

          }

 

改为:

if (button != null && button.m_defaultMenuItem != menuItem)
            {
      

               button.m_defaultMenuItem.IsEnabledChanged += delegate(object o, DependencyPropertyChangedEventArgs args)
                {
                    MenuItem currentMenu = o as MenuItem;
                    if (contentControl != null && button.m_defaultMenuItem == currentMenu)
                        contentControl.IsEnabled = (bool)args.NewValue;
                };

          }

 

 

posted on 2008-10-20 12:27  oyl  阅读(156)  评论(0编辑  收藏  举报

导航