Gustavo Gonçalves
Gustavo Gonçalves

Reputation: 539

Frame ViewModel

I would like information on how to load a Frame through a viewmodel. I know how to load through the code-behind, but now want to move everything to the ViewModel linking frame.content or other property of binding to a Frame.

Do you have tips or suggestions?

Upvotes: 0

Views: 1773

Answers (2)

ArielBH
ArielBH

Reputation: 2001

My answer is a bit off subject, cause I'm taking a leap here on what you are really trying to accomplish.

If you are looking for navigation implementation, you might consider other approaches.

  1. Use Prism's Navigation feature, the RegionManager abstracts enough that you can just use it in your VM and navigate to a Uri.
  2. Use a TabControl that you can strip out the headers with a simple style. Now you can bind the TabControl SelectedItem to the VM, imagine every tab is a view (or a VM) you can now control navigation with a matter of switching tabs.

HTH Ariel

Upvotes: 3

Jon Dosmann
Jon Dosmann

Reputation: 737

Bind the contents of the frame to a Page object

<Page>
    <Viewbox Stretch="Fill" Margin="15">
        <Frame Height="800" Width="1280" Content="{Binding SlideFrame}"/>
    </Viewbox>
</Page>
using System.Windows.Controls;

private Page _slideFrame;

// Property
public Page SlideFrame
{
    get { return _slideFrame; }
    set
    {
        _slideFrame = value;
        NotifyPropertyChanged("SlideFrame");
    }
}

Upvotes: 1

Related Questions