Quanta
Quanta

Reputation: 465

WPF Frame Navigation

I'm pretty new to WPF and implementing it via MVVM, and I'm trying to develop an application with no code-behind to help break my hold ways of thinking about UI design. Anyways, to the point: In my XAML, I have a Window which contains a Frame which will host various pages that I've created in seperate xaml files. I'd like for the buttons contained in the various pages that the frame will host to facilitate the frame's navigation. I realize I could put the buttons on the window, but that's not what I'm going for here; I need them in whatever page the frame happens to be pointing to at the time. I thought that this would work:

<Button Style="{StaticResource NavigationButton}" Content="Design" Grid.Row="0" Grid.Column="0" Command="NavigationCommands.GoToPage" CommandParameter="DesignMenu.xaml" />

but the button is grayed out :( I figured that since the page was hosted within the frame, and that because frames can handle navigation commands, that the command would magically bubble up, get to the frame eventually, and the frame's source attribute would change to designmenu.xaml? I also tried specifying a target for the command by referencing the frame's name, but the page doesn't "See" the frame since they're in separate files, so that doesn't work either. Any insights or best practices are welcome.

Upvotes: 2

Views: 7774

Answers (1)

Quanta
Quanta

Reputation: 465

Well, if anyone was curious, after days of beating my head against a desk, I discovered that a Hyperlink object does exactly what I'm looking for here. It's just a matter of dressing it up to look like a button, and voila. This MSDN Overview helped: MSDN WPF Navigation Overview

Upvotes: 1

Related Questions