1

我终于设法将我的功能区模板化并使用数据绑定添加所有内容。但是我有一个非常丑陋的“下拉菜单”,其背景变得透明(阴影仍然存在!)

在此处输入图像描述

首先,这个“下拉菜单”叫什么?最后,我应该编辑哪些属性来为这个“下拉菜单”提供适当的背景?

此致!

4

1 回答 1

0

该菜单是折叠组的下拉菜单。折叠组是RibbonToggleButton+的组合Popup。在模板中,Popup看起来像这样:

<Popup x:Name="PART_Popup"
                    AllowsTransparency="true"
                    Placement="Bottom"                               
                    PlacementTarget="{Binding ElementName=PART_ToggleButton}"
                    IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
                    Focusable="false"
                    PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
    <classic:SystemDropShadowChrome Name="Shdw" 
                                Color="Transparent" 
                                SnapsToDevicePixels="true" 
                                CornerRadius="2" 
                                Focusable="True" 
                                FocusVisualStyle="{x:Null}"
                                controls:KeyTipService.IsKeyTipScope="True"

                                RenderOptions.ClearTypeHint="Enabled"

                                >
        <Grid Name="PopupGrid" Height="{TemplateBinding ActualHeight}" Margin="0,1.5,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" MinHeight="16" />
            </Grid.RowDefinitions>
            <Border Name="PopupBorder" Grid.RowSpan="2"
                Background="{TemplateBinding Background}"
                BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Ribbon.BorderBrush}"
                BorderThickness="1"/>
            <Border Name="PART_HotBackground"
                Background="{TemplateBinding MouseOverBackground}"
                BorderBrush="{TemplateBinding MouseOverBorderBrush}"
                Opacity="0"
                Grid.RowSpan="2"
                CornerRadius="2"
                BorderThickness="1"
                SnapsToDevicePixels="True"/>
            <Border Margin="2,3.5,2,0" Padding="3,0,3,0" x:Name="PART_RibbonControlsHostBorder">
                <Grid>
                    <ItemsPresenter Name="ItemsPresenter" KeyboardNavigation.TabNavigation="Cycle"
                                        KeyboardNavigation.DirectionalNavigation="Cycle"
                                        SnapsToDevicePixels="True"
                                        Grid.IsSharedSizeScope="true"/>
                    <ContentControl Name="TemplateContentControl" Visibility="Collapsed" Focusable="False"/>
                </Grid>
            </Border>
            <Grid Margin="2,0,2,1" Grid.Row="1">
                <ContentPresenter Name="PART_Header"
                                TextElement.Foreground="{StaticResource &#203;}"
                                ContentSource="Header"
                                Margin="2,0,2,0"
                                MaxHeight="15"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"/>
            </Grid>
        </Grid>
    </classic:SystemDropShadowChrome>
</Popup>

如您所见,Background继承自RibbonGroup. 所以,你有几个变种来修复它:

  1. 为您设置不透明的Background属性RibbonGroup
  2. 重新模板
于 2014-03-28T15:49:37.293 回答