MenuItem IsEnable Binding Issue

2 posts, 1 answers
  1. Shyu
    Shyu avatar
    10 posts
    Member since:
    Oct 2013

    Posted 20 Nov 2013 Link to this post

    Hello telerik.
    I am using RadControls for Silverlight Q1 2012 SP1.
    And found there is a issue about RadMenuItem IsEnableProperty Binding.
    I did a project like this.
    <telerik:RadMenu>
                <telerik:RadMenu.Items>
                    <telerik:RadMenuItem x:Name="test" Header="制御" IsEnabled="{Binding IsEnableMenu}" />
                </telerik:RadMenu.Items>
            </telerik:RadMenu>
            <Button Content="Test" Click="Button_Click"/>

    public partial class MainPage : UserControl
        {
            MainViewModel _mainView;
     
            public MainPage()
            {
                InitializeComponent();
     
     
                this._mainView = new MainViewModel();
     
                this.DataContext = this._mainView;
            }
     
            private void HousasToolBarItem_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
            {
                this._mainView.IsEnableMenu = !this._mainView.IsEnableMenu;
            }
     
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                this._mainView.IsEnableMenu = !this._mainView.IsEnableMenu;
            }
        }
    public class MainViewModel : ViewModelBase
        {
            public bool IsEnableMenu
            {
                get { return isEnableMenu; }
                set
                {
                    isEnableMenu = value;
                    OnPropertyChanged("IsEnableMenu");
                }
            }
            private bool isEnableMenu;
        }

    When I start the project, the menu IsEnableProperty is false, i clicked the button, it becomes true. When i click the button again, It never becomes false.

    Was there something wrong with what i did?


  2. Answer
    Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 21 Nov 2013 Link to this post

    Hello Shyu,

    Whenever you want to bind the IsEnabled property you should use a TwoWay binding. It is designed that way because of some limitations of Silverlight framework. Please try the following and should start working as expected:
    <telerik:RadMenuItem x:Name="test" Header="制御" IsEnabled="{Binding IsEnableMenu, Mode=TwoWay}" />

    Hope this helps.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top