0

我正在构建一个 MVVM Panorama Windows Phone 7 应用程序。

在全景项目布局的某个点,我得到全景标题框的底部边距,这将我的内容移动得太远了。有没有办法可以设置 a 的下边距ContentPresenter,它是为保存控件而生成的,在Panorama.HeaderTemplate?

这是我在 Silverlight Spy 中的布局列表: 保证金问题

如果屏幕截图不可读,这里是一个大版本: http ://bit.ly/rBvNp8

有些东西会为标题框(可能是处理布局的控件代码)生成 26 磅的底部边距。我怎样才能控制这个值?我需要将其设置为 0。

4

1 回答 1

1

为了控制 aContentPresenter的属性,需要重新定义 PanoramaItem 的默认模板(在样式设置器中)。在我的特殊情况下,它是PanoramaItem's 风格。

<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>

设置Margin="10,-2​​,0,0"可以解决问题。

于 2011-11-12T12:14:31.673 回答