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 Al,
After reviewing this, our developers said that two instances of the ViewModel are created. One in XAML and the other one in code behind and this is the reason the property is not updated. I have modified the sample I have sent you before, so now it uses only the viewmodel from the XAML and everything works as expected.
Please let me know if you have further questions on this matter.
Looking forward for your reply.
Hello,
I have logged this with development under ID: 186627 and I have also created a support ticket on your behalf: CAS-148469-Z8J6N7 and have linked the development issue to it, so that you can get automatically updated, when a Service Release containing the fix is available for download. You can get the new version from our website’s “My IG”, “My Keys & Downloads” tags: https://es.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads
You can also monitor the support ticket’s progress through the “My Support Activity” tag: https://es.infragistics.com/Membership/MySupport.aspx
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.
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.