Implementing commands in MMVM

Posted by user312372 on Stack Overflow See other posts from Stack Overflow or by user312372
Published on 2010-04-09T01:55:04Z Indexed on 2010/04/09 2:23 UTC
Read the original article Hit count: 462

Filed under:

I am trying to change the source property of the frame in Page1.xaml when the SampleCommand is excecuted. How do I acheive this in the View Model?

Page1.xaml:

<Page ...>
<DockPanel>
    <r:ribbon>         
        <r:RibbonTab Label="Keys">
            <r:RibbonTab.Groups>
                <r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}">
                    <r:RibbonGroup.Command>
                        <r:RibbonCommand LabelTitle="RibbonButton"/>
                    </r:RibbonGroup.Command>
                    <r:RibbonButton x:Name="RibbonButton1" Command="{Binding Path=SampleCommand}"/>
                </r:RibbonGroup>
            </r:RibbonTab.Groups>
        </r:RibbonTab>
    </r:Ribbon>

    <Border Name="PageBorder" Grid.Row="0" Grid.Column="1">
        <Frame Name="pageFrame" Source="FirstPage.xaml" />

    </Border>
</DockPanel>
</Page>

Page1ViewModel.cs:

RelayCommand _sampleCommand;

public ICommand SampleCommand
{
    get
    {
        // create command ??

        return _sampleCommand 
    }
}

page1.xaml.cs:

Page1ViewModel pageViewModel;

//When page loads

this.DataContext = pageViewModel;

© Stack Overflow or respective owner

Related posts about wpf