2011-11-12 18 views
0

我正在構建MVVM全景Windows Phone 7應用程序。Windows Phone全景控制中自動生成的內容演示者的控制邊距

在Panorama Item的佈局的某個點,我得到了全景標題框的底部邊距,這會將我的內容向下移動太遠。有沒有一種方法可以設置ContentPresenter的底部邊距,即生成用於容納控件的邊界,在Panorama.HeaderTemplate中定義?

這裏是Silverlight的間諜我的佈局列表: margin problem

萬一屏幕截圖不可讀,這裏是一個大的版本: http://bit.ly/rBvNp8

東西產生26點底部邊緣頭球框(可能是控件的代碼,處理佈局)。我怎樣才能控制這個值?我需要將它設置爲0.

回答

1

爲了控制ContentPresenter的屬性,需要重新定義PanoramaItem的默認模板(在樣式設置器中)。在我的特殊情況下,它是PanoramaItem的風格。

<Style TargetType="controls:PanoramaItem"> 
      <Setter Property="CacheMode" Value="BitmapCache"/> 
      <Setter Property="HorizontalContentAlignment" Value="Stretch"/> 
      <Setter Property="VerticalContentAlignment" Value="Stretch"/> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="controls:PanoramaItem"> 
         <Grid Background="{TemplateBinding Background}" Margin="12,0,0,0"> 
          <Grid.RowDefinitions> 
           <RowDefinition Height="auto"/> 
           <RowDefinition Height="*"/> 
          </Grid.RowDefinitions> 
          <ContentControl x:Name="header" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" FontSize="{StaticResource PhoneFontSizeExtraExtraLarge}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" Margin="10,-2,0,0"> 
           <ContentControl.RenderTransform> 
            <TranslateTransform x:Name="headerTransform"/> 
           </ContentControl.RenderTransform> 
          </ContentControl> 
          <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Grid.Row="1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> 
         </Grid> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

設置保證金= 「10,-2,0,0」的伎倆。