0
votes

I'm trying to bind IsEnabled property of AppBarButton to ToggleButton in XAML and it just doesn't work. There are no error messages or warnings. I can check or uncheck ToggleButton but nothing happens with AppBarButton. I have no idea where the problem is. Here's sample code:

<Page.BottomAppBar>
    <CommandBar>
        <AppBarButton IsEnabled="{Binding IsChecked, ElementName=button}"/>
    </CommandBar>
</Page.BottomAppBar>

<Grid>
    <ToggleButton x:Name="button" Content="ToggleButton"/>
</Grid>

1
Did you manage to find the solution to your problem? I'm having (almost) the same problem right now. - Jesse de Wit
Well, nope. I have noticed that TogleButton.IsChecked property is nullable bool and then I tried to use a converter but it didn't work either. So I made a workaround: AcceptCheckBox.Click += (s, a) => { var conv = new NullableBoolToBoolConverter(); AcceptButton.IsEnabled = (bool)conv.Convert(AcceptCheckBox.IsChecked, typeof(bool), null, ""); }; - saorist

1 Answers

0
votes

I think that the DataContext of the page is not active for the BottomAppBar or TopAppBar. Set the DataContext of the CommandBar manually to the DataContext of the Page.