I've been trying to implement Microsoft's hamburger pattern in my own way for some time.
Final result was the following:
- AppShell for containing current page and hamburger menu (menu always visible)
- In Appshell, Grid with two rows: one 48px in height, one one-start height.
- In first row, added a commandbar (global), and hamburger button (togglebutton with custom style for being 48px wide and tall, with the hamburger fonticon in the center)
- In second row, SplitView with a ListBox on the Pane, and a Frame in the Content.
This way one has control over the content, while displaying a global menu and command bar. On the Navigated event of the Frame, I update the CommandBar to pull the primary and secondary commands from the Frame's Content's properties (I use a custom page control with those properties), and the content of the CommandBar (which is, of now, a single TextBlock with binding).
However, I wanted to move the ToggleButton into the CommandBar. It worked nicely, except the binding (IsChecked of ToggleButton is bound to IsPaneOpen of SplitView) does not work. I use the regular ElementName targeting, and would prefer to not to use a ViewModel property.
Does the CommandBar.Content use a different context? Or why doesn't the ElementName reference work?
x:Bind
? have you set theMode
property correctly? – Markus HütterBinding
, notx:Bind
. Mode is set properly (TwoWay), but it's like the property change never fires. If I copy-paste the exact code of the ToggleButton out of the CommandBar, it works fine. If inside the Content of the Commandbar, it stops working. – fonix232IsPaneOpen="{Binding IsChecked, ElementName=Toggle}"
– Markus Hütter