This is a migrated thread and some comments may be shown as answers.

MenuItem IsEnable Binding Issue

1 Answer 59 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Shyu
Top achievements
Rank 1
Shyu asked on 20 Nov 2013, 06:07 AM
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?


1 Answer, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 21 Nov 2013, 11:36 AM
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 >>
Tags
Menu
Asked by
Shyu
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or