I want to disable or hide a button in my ribbon group:
<ig:XamRibbonGroup Caption="Tune" x:Name="TuneGroup" > <ig:ButtonTool x:Name="TuneButton" Caption="Tune" IsEnabled="{Binding IsTuningEnabled, Source={StaticResource RTSolutionViewModel}}" SmallImage="Ribbon/Query/Edit16x16.png" LargeImage="Ribbon/Query/Edit32x32.png" MinimumSize="ImageOnly" MaximumSize="ImageAndTextLarge" Command="{Binding TuneCommand, Source={StaticResource RTSolutionViewModel}}" Click="TuneRadioButton_Click" />The IsEnabled property doesn't have any effect on the button. It is always enabled.How do I do this?
Hello,
Thank you for your post. I have been looking into it and I created a sample project for you following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.
Thanks for the example. Now let's take it a step further. When IsButtonEnabled is set to true in the vm, the btn should be enabled. I'd send this back as a zip but cant see how to do that in this tool.
<Grid x:Name="LayoutRoot" Background="White" > <Grid.Resources> <local:IdentityConverter x:Key="IdentityConverter" /> <local:ViewModel x:Key="vm"/> </Grid.Resources> <ig:XamRibbon > <ig:XamRibbon.Tabs> <ig:XamRibbonTabItem> <ig:XamRibbonGroup Caption="group1" > <ig:ButtonTool x:Name="btnButton1" Caption="button1" IsEnabled="{Binding Source={StaticResource vm}, Path=IsButtonEnabled, Mode=OneWay, Converter ={StaticResource IdentityConverter}}"/> </ig:XamRibbonGroup> </ig:XamRibbonTabItem> </ig:XamRibbon.Tabs> </ig:XamRibbon> <Button Content="Enable" HorizontalAlignment="Left" Margin="23,159,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/> </Grid>
namespace SilverlightApplication2{ public partial class MainPage : UserControl { private ViewModel viewModel; public MainPage() { InitializeComponent(); viewModel = new ViewModel(); this.DataContext = viewModel; } private void Button_Click(object sender, RoutedEventArgs e) { viewModel.toggleEnable(); } } public class ViewModel : INotifyPropertyChanged { private bool _IsButtonEnabled; public bool IsButtonEnabled { get { return _IsButtonEnabled; } set { if (_IsButtonEnabled != value) { _IsButtonEnabled = value; NotifyPropertyChanged("IsButtonEnabled"); } } } public ViewModel() { IsButtonEnabled = false; } public void toggleEnable() { if (IsButtonEnabled) { IsButtonEnabled = false; } else { IsButtonEnabled = true; } } public event PropertyChangedEventHandler PropertyChanged; protected void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } }}
I cant for the life of me get the PropertyChanged event to fire.