none
如何在VC#2010的WPF4版本中将XMAL的RibbonQuickAccessToolBar.Placement实现,即快捷工具栏的客户自定义功能 RRS feed

  • 问题

  • <DockPanel>
        <
    r:Ribbon DockPanel.Dock="Top" FocusManager.IsFocusScope="True" Title="WPF4 Notepad"> <r:Ribbon.QuickAccessToolBar>
                <
    r:RibbonQuickAccessToolBar>
                    <
    r:RibbonButton r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar"
                                   
    Command="{StaticResource SaveCommand}" />
                    <
    r:RibbonButton r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar"
                                   
    Command="{StaticResource ClearCommand}" />
                    <
    r:RibbonButton r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar"
                                   
    Command="{StaticResource HelpCommand}" />
                </
    r:RibbonQuickAccessToolBar>
            </
    r:Ribbon.QuickAccessToolBar>
        </r:Ribbon>
    </
    DockPanel>
    2011年4月2日 8:24

答案

  • 首先,我不确定你使用的那个版本的Ribbon For WPF,看上去并不是最新的版本,是以前的老版本,新版本中已经没有了 RibbonQuickAccessToolBar.Placement 这个附加属性了。你可以从这里下载到最新的版本:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2bfc3187-74aa-4154-a670-76ef8bc2a0b4

    然后,在新版本中,设计使用 RibbonQuickAccessToolBar 应该如下:

    <ribbon:RibbonWindow x:Class="WpfRibbonApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
            Title="MainWindow"
    		x:Name="RibbonWindow"
    		Width="640" Height="480">
     
      <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
     
        <ribbon:Ribbon x:Name="Ribbon">
          <ribbon:Ribbon.QuickAccessToolBar>
            <ribbon:RibbonQuickAccessToolBar>
              <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" />
              <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" />
              <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" />
            </ribbon:RibbonQuickAccessToolBar>
          </ribbon:Ribbon.QuickAccessToolBar>
     
          <ribbon:RibbonTab x:Name="HomeTab" 
                                  Header="Home">
            <ribbon:RibbonGroup x:Name="Group1" 
                                        Header="Group1">
              <ribbon:RibbonButton x:Name="Button1"
                                             LargeImageSource="Images\LargeIcon.png" SmallImageSource="Images\SmallIcon.png"
                                             Label="Button1" 
                                  CanAddToQuickAccessToolBarDirectly="True" QuickAccessToolBarId="Button1"/>
     
              <ribbon:RibbonButton x:Name="Button2"
                                             SmallImageSource="Images\SmallIcon.png"
                                             Label="Button2" 
                                   CanAddToQuickAccessToolBarDirectly="True" QuickAccessToolBarId="Button2"/>
              <ribbon:RibbonButton x:Name="Button3"
                                             SmallImageSource="Images\SmallIcon.png"
                                             Label="Button3" 
                                   CanAddToQuickAccessToolBarDirectly="True" QuickAccessToolBarId="Button3"/>
              <ribbon:RibbonButton x:Name="Button4"
                                             SmallImageSource="Images\SmallIcon.png"
                                             Label="Button4" 
                                   CanAddToQuickAccessToolBarDirectly="True" QuickAccessToolBarId="Button4"/>
     
            </ribbon:RibbonGroup>
     
          </ribbon:RibbonTab>
        </ribbon:Ribbon>
     
      </Grid>
    </ribbon:RibbonWindow>
    

    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年4月3日 6:57
    版主

全部回复

  • <r:RibbonQuickAccessToolBar>
            <r:RibbonButton r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar"
                    Command="{StaticResource SaveCommand}" />
            <r:RibbonButton r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar"
                    Command="{StaticResource ClearCommand}" />
            <r:RibbonButton r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar"
                    Command="{StaticResource HelpCommand}" />
          </r:RibbonQuickAccessToolBar>
    
    2011年3月31日 7:03
  • 首先,我不确定你使用的那个版本的Ribbon For WPF,看上去并不是最新的版本,是以前的老版本,新版本中已经没有了 RibbonQuickAccessToolBar.Placement 这个附加属性了。你可以从这里下载到最新的版本:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2bfc3187-74aa-4154-a670-76ef8bc2a0b4

    然后,在新版本中,设计使用 RibbonQuickAccessToolBar 应该如下:

    <ribbon:RibbonWindow x:Class="WpfRibbonApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
            Title="MainWindow"
    		x:Name="RibbonWindow"
    		Width="640" Height="480">
     
      <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
     
        <ribbon:Ribbon x:Name="Ribbon">
          <ribbon:Ribbon.QuickAccessToolBar>
            <ribbon:RibbonQuickAccessToolBar>
              <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" />
              <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" />
              <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" />
            </ribbon:RibbonQuickAccessToolBar>
          </ribbon:Ribbon.QuickAccessToolBar>
     
          <ribbon:RibbonTab x:Name="HomeTab" 
                                  Header="Home">
            <ribbon:RibbonGroup x:Name="Group1" 
                                        Header="Group1">
              <ribbon:RibbonButton x:Name="Button1"
                                             LargeImageSource="Images\LargeIcon.png" SmallImageSource="Images\SmallIcon.png"
                                             Label="Button1" 
                                  CanAddToQuickAccessToolBarDirectly="True" QuickAccessToolBarId="Button1"/>
     
              <ribbon:RibbonButton x:Name="Button2"
                                             SmallImageSource="Images\SmallIcon.png"
                                             Label="Button2" 
                                   CanAddToQuickAccessToolBarDirectly="True" QuickAccessToolBarId="Button2"/>
              <ribbon:RibbonButton x:Name="Button3"
                                             SmallImageSource="Images\SmallIcon.png"
                                             Label="Button3" 
                                   CanAddToQuickAccessToolBarDirectly="True" QuickAccessToolBarId="Button3"/>
              <ribbon:RibbonButton x:Name="Button4"
                                             SmallImageSource="Images\SmallIcon.png"
                                             Label="Button4" 
                                   CanAddToQuickAccessToolBarDirectly="True" QuickAccessToolBarId="Button4"/>
     
            </ribbon:RibbonGroup>
     
          </ribbon:RibbonTab>
        </ribbon:Ribbon>
     
      </Grid>
    </ribbon:RibbonWindow>
    

    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年4月3日 6:57
    版主