Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

AJBM

[Resolvido] Criar Ribbon

Recommended Posts

AJBM

Boas!

Eu tenho esta view.

<Window x:Class="WpfApplication2.Views.MainWindowView"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:views="clr-namespace:WpfApplication2.Views"
	xmlns:prism="http://prismlibrary.com/"
	prism:ViewModelLocator.AutoWireViewModel="True"	  
	Title="MainWindow" Height="350" Width="525">
<Grid>
	<!--<Ribbon Name="myRibbon" HorizontalAlignment="Left" VerticalAlignment="Top" Width="517" Height="75">
	</Ribbon>-->
	<Grid.RowDefinitions>
		<RowDefinition Height="37*"/>
		<RowDefinition Height="282*"/>
	</Grid.RowDefinitions>
	<Button Content="View A"
			HorizontalAlignment="Left" Margin="36,10,0,0" VerticalAlignment="Top"
			Width="75" Command="{Binding NavigateCommnad}" CommandParameter="ViewA"/>
	<Button Content="ViewB" HorizontalAlignment="Left" Margin="138,10,0,0" VerticalAlignment="Top" Width="75" Command="{Binding NavigateCommnad}" CommandParameter="ViewB"/>
	<ContentControl  HorizontalAlignment="Left" Margin="50,76,0,0" Grid.Row="1" VerticalAlignment="Top"  Width="431" Height="175"
					 prism:RegionManager.RegionName="ContentRegion" >
	</ContentControl>


</Grid>
</Window>
Quando eu clico no botão ViewA é apresentado um usercontrol dentro da própria window.

Eu quero substituir os botões por uma ribbon e quero que cada user control seja responsável por construir a sua própria RibbonTab.(Ribbon groups, Ribbon buttons,...).

Mas só quando é clicada.

Tenho uma interface IRibbonTab

public interface IRibbonTab
{
	 void BuildRibbonTab(RibbonTab pRibbonTab);
}
Todas os UserControls implementam esta interface.
  public partial class ViewA : UserControl, IRibbonTab
{
	public ViewA()
	{
		InitializeComponent();
	}

	public void BuildRibbonTab(RibbonTab pRibbonTab)
	{

			RibbonGroup group = new RibbonGroup();
			group.Header = "Group1";				
RibbonButton button = new RibbonButton();
			button.Label = "Button";
			group.Items.Add(button);
			pRibbonTab.Items.Add(group);

	}
}
 

O processo de navegação da Region é definido na MainWindowViewModel

 public class MainWindowViewModel : BindableBase
{
	private readonly IRegionManager myRegionManager;
	public DelegateCommand<string> NavigateCommnad { get; set; }
	public MainWindowViewModel(IRegionManager pRegionManager)
	{
		myRegionManager = pRegionManager;
		NavigateCommnad = new DelegateCommand<string>(Navigate);
	}

	private void Navigate(string url)
	{
		myRegionManager.RequestNavigate("ContentRegion", url, CallBack);
	}
	private void CallBack(NavigationResult obj)
	{
	}

}
 

A minha dúvida é como é que eu passo RibbonTab que foi clicada para o UserControl.

Ps: Se for possível mover este tópico para um quadro mais indicado.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.