2017-08-28 50 views
0

我試圖創建一個窗口Chrome的使用按鈕,但我沒能拿到冠軍的文字和圖片,對這個MSDN的一個例子,但它也有一些關鍵字在VS2015SystemParameter在MSDN例如

不工作
<Style x:Key="StandardStyle" TargetType="{x:Type local:MainWindow}"> 
<Setter Property="WindowChrome.WindowChrome"> 
    <Setter.Value> 
     <WindowChrome /> 
    </Setter.Value> 
</Setter> 
<Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="{x:Type local:MainWindow}"> 
      <Grid> 
       <Border Background="White" 
         Margin="{Binding Source={x:Static **SystemParameters2.Current**}, Path=WindowNonClientFrameThickness}"> 
        <ContentPresenter Content="{TemplateBinding Content}" /> 
       </Border> 
       <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" 
          VerticalAlignment="Top" HorizontalAlignment="Left" 
          Margin="36,8,0,0"/> 
       <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon}" 
         VerticalAlignment="Top" HorizontalAlignment="Left" 
         Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(WindowChrome.WindowChrome).ResizeBorderThickness}" 
         Width="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=SmallIconSize.Width}" 
         WindowChrome.IsHitTestVisibleInChrome="True"/> 
      </Grid> 
     </ControlTemplate> 
    </Setter.Value> 
</Setter> 

這個例子中的「SystemParameters2.Current」是什麼?它是一些系統參數還是用戶定義的? Example by MSDN

回答

1

在VS2015/.NET框架4.5有一個SystemParameters類在PresentationFramework組件可用的包含所述WindowNonClientFrameThicknessSmallIconWidth屬性,以便等效將是:

<Grid> 
    <Border Background="White" 
        Margin="{Binding Source={x:Static SystemParameters.WindowNonClientFrameThickness}}"> 
     <ContentPresenter Content="{TemplateBinding Content}" /> 
    </Border> 
    <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" 
          VerticalAlignment="Top" HorizontalAlignment="Left" 
          Margin="36,8,0,0"/> 
    <Image ... 
         Width="{Binding Source={x:Static SystemParameters.SmallIconWidth}" 
         WindowChrome.IsHitTestVisibleInChrome="True"/> 
</Grid>