2011-10-30 8 views
3

私はWindowStyleがNoneに設定されているRibbonWindowを持っていますので、グリップがウィンドウのサイズを変更するのは何ですか?コントロールのマージンが0に設定されていても、その下の部分は非表示になります...これは異常な動作です。 ...WPF RibbonWindowがウィンドウのサイズを変更するグリップを表示しない

を、私はそれは大丈夫だコントロールの下の余白を変更するが、グリップはおそらくクライアント領域の一部が隠されているので、とにかく見ることができない場合

は、しかし、私はあれば、言っていますWPFウィンドウを持っていますが、これは起こらず、RibbonWindowでのみ発生します。そして、私はリボンが適切なウィンドウで他の外観を持っているので、RibbonWindowを使用しています。

グリップの問題を解決するにはどうすればよいですか?

私のコードのいくつか...事前に

<rib:RibbonWindow x:Class="MyApp.Views.MainView" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:rib="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" 
        AllowsTransparency="True" 
        Background="Transparent" 
        Height="750" 
        ResizeMode="CanResizeWithGrip" 
        Width="1000" 
        WindowStartupLocation="CenterScreen" 
        WindowStyle="None"> 

    <Grid Margin="0, 0, 0, 20"> 
     <Border Background="Black" 
       CornerRadius="5" 
       Opacity="0.5"/> 
    </Grid> 
</rib:RibbonWindow> 

ありがとう!

答えて

7

これはデバッグが面白かったです。ウィンドウのスタイルにはバグがあります。システムがIsGlassEnabled == true(Win7 Aeroテーマではtrueになります)と定義されている場合、ウィンドウはMicrosoft.Windows.Shell.WindowChrome(Microsoft.Windows.Shellアセンブリ)を使用して、枠線とウィンドウの上部ボタンを描画します。このWindowChromeはと組み合わせて8,30,8,8に設定されたGlassFrameThicknessプロパティがBottomに設定されています。

何が起こるするためAllowsTransparency == trueのガラス境界は透明であるが、WindowChromeは、このようにビューからResizeGripを切断、NonClientFrameEdges="Bottom"を定義するためのウィンドウがまだ全体ウィンドウサイズから、その厚さを「切断する」ことです。

画面上にウィンドウをドラッグすると、これが表示されます。ResizeGripがちらついて表示されます。

:我々は NonClientFrameEdges="None"(または GlassFrameThickness = 0あるいはその両方)を使用して新しい WindowChromeを定義し、 IsGlassEnabled == true && AllowsTransparency == true(私はApp.xamlで定義されたアプリケーションリソースを使用してのみ NonClientFrameEdges="None"を定義しています)場合にのみ、ウィンドウに割り当てる必要があり、これを解決するために

1. Add these namespaces to App.xaml: 
    xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" 
    xmlns:ribbonPrimitives="clr-namespace:Microsoft.Windows.Controls.Ribbon.Primitives;assembly=RibbonControlsLibrary" 
    xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell" 

2. Add these resources: 
    <ribbonPrimitives:RibbonWindowSmallIconConverter x:Key="RibbonWindowSmallIconConverter" /> 
    <shell:WindowChrome x:Key="WindowChromeWithGlassAndTransparency" 
         NonClientFrameEdges="None" /> 
    <Style x:Key="MyStyle" 
      TargetType="{x:Type ribbon:RibbonWindow}"> 
     <Style.Triggers> 
      <MultiDataTrigger> 
       <MultiDataTrigger.Conditions> 
        <Condition Binding="{Binding Path=IsGlassEnabled, Source={x:Static shell:SystemParameters2.Current}}" 
           Value="True" /> 
        <Condition Binding="{Binding AllowsTransparency, RelativeSource={RelativeSource Mode=Self}}" 
           Value="False" /> 
       </MultiDataTrigger.Conditions> 
       <Setter Property="shell:WindowChrome.WindowChrome" 
         Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type ribbon:Ribbon}, ResourceId=WindowChromeAeroWithGlass}}" /> 
      </MultiDataTrigger> 
      <MultiDataTrigger> 
       <MultiDataTrigger.Conditions> 
        <Condition Binding="{Binding Path=IsGlassEnabled, Source={x:Static shell:SystemParameters2.Current}}" 
           Value="True" /> 
        <Condition Binding="{Binding AllowsTransparency, RelativeSource={RelativeSource Mode=Self}}" 
           Value="True" /> 
       </MultiDataTrigger.Conditions> 
       <Setter Property="shell:WindowChrome.WindowChrome" 
         Value="{DynamicResource WindowChromeWithGlassAndTransparency}" /> 
      </MultiDataTrigger> 
      <DataTrigger Binding="{Binding Path=IsGlassEnabled, Source={x:Static shell:SystemParameters2.Current}}" 
         Value="True"> 
       <!--This is the original setter of the chrome that makes all the trouble--> 
       <!--<Setter Property="shell:WindowChrome.WindowChrome" 
        Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type ribbon:Ribbon}, ResourceId=WindowChromeAeroWithGlass}}" />--> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="{x:Type ribbon:RibbonWindow}"> 
          <Grid> 
           <Border Name="PART_ClientAreaBorder" 
             Background="{TemplateBinding Control.Background}" 
             BorderBrush="{TemplateBinding Control.BorderBrush}" 
             BorderThickness="{TemplateBinding Control.BorderThickness}" 
             Margin="{Binding Path=WindowNonClientFrameThickness, Source={x:Static shell:SystemParameters2.Current}}" /> 
           <Border BorderThickness="{Binding Path=(shell:WindowChrome.WindowChrome).ResizeBorderThickness, RelativeSource={RelativeSource TemplatedParent}}"> 
            <Grid> 
             <Image Name="PART_Icon" 
               shell:WindowChrome.IsHitTestVisibleInChrome="True" 
               HorizontalAlignment="Left" 
               VerticalAlignment="Top" 
               Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon, Converter={StaticResource RibbonWindowSmallIconConverter }}" 
               Width="{Binding Path=SmallIconSize.Width, Source={x:Static shell:SystemParameters2.Current}}" 
               Height="{Binding Path=SmallIconSize.Height, Source={x:Static shell:SystemParameters2.Current}}" /> 
             <AdornerDecorator> 
              <ContentPresenter Name="PART_RootContentPresenter" /> 
             </AdornerDecorator> 
             <ResizeGrip Name="WindowResizeGrip" 
                shell:WindowChrome.ResizeGripDirection="BottomRight" 
                HorizontalAlignment="Right" 
                VerticalAlignment="Bottom" 
                Visibility="Collapsed" 
                IsTabStop="False" /> 
            </Grid> 
           </Border> 
          </Grid> 
          <ControlTemplate.Triggers> 
           <Trigger Value="{x:Null}" 
             Property="Icon"> 
            <Setter TargetName="PART_Icon" 
              Property="Source" 
              Value="/RibbonControlsLibrary;component/Images/GlassyDefaultSystemIcon.png" /> 
           </Trigger> 
           <Trigger Property="WindowState" 
             Value="Maximized"> 
            <Setter TargetName="PART_Icon" 
              Property="Margin" 
              Value="0,2,0,0" /> 
           </Trigger> 
           <MultiTrigger> 
            <MultiTrigger.Conditions> 
             <Condition Property="ResizeMode" 
                Value="CanResizeWithGrip" /> 
             <Condition Property="WindowState" 
                Value="Normal" /> 
            </MultiTrigger.Conditions> 
            <Setter TargetName="WindowResizeGrip" 
              Property="Visibility" 
              Value="Visible" /> 
           </MultiTrigger> 
          </ControlTemplate.Triggers> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </DataTrigger> 
     </Style.Triggers> 
    </Style> 

3. In your window use the new style: 
    <rib:RibbonWindow .... 
         Style="{StaticResource MyStyle}"> 

     .... 
    </rib:RibbonWindow> 

DataTriggerは、元のスタイルとほぼ同じですが、修正は1つしかありません。私は、セッターにWindowChromeをコメントしました。

MultiDataTriggerが私の追加です。彼らはプロパティの値をチェックし、値がの場合は元の値、trueの場合はNonClientFrameEdges="None"の値を返します(GlassFrameThickness = 0でもかまいません)。

注:このソリューションは、エッジを使用してウィンドウのサイズを変更する機能を削除します。ウィンドウのサイズ変更は、ResizeGripによってのみ行われます。

関連する問題