0
我试图在SampleCommand被执行时更改Page1.xaml中的帧的源属性。 我如何在视图模型中实现这一点?MVVM和Ribbon命令
的Page1.xaml:
<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>
C# Page1ViewModel.cs:
RelayCommand _sampleCommand;
public ICommand SampleCommand
{
get
{
// create command ??
return _sampleCommand
}
page1.xaml.cs:
Page1ViewModel pageViewModel;
this.DataContext = pageViewModel; //当页面加载时