在 Windows Phone 全景控件中控制自动生成的内容演示者的边距

发布于 2024-12-15 05:55:05 字数 471 浏览 4 评论 0原文

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

在全景项目布局的某个点,我得到全景标题框的下边距,这将我的内容向下移动得太远。有没有办法设置 ContentPresenter 的下边距,生成该内容以容纳 Panorama.HeaderTemplate 中定义的控件?

这是我在 Silverlight Spy 中的布局列表: margin Problem

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

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

I am building an MVVM Panorama Windows Phone 7 application.

At some point of Panorama Item's layout I get a bottom margin of a panorama header box, that moves my content too far down. Is there a way I can set a bottom margin of a ContentPresenter, that is generated to hold the controls, defined in the Panorama.HeaderTemplate?

Here is my layout list in Silverlight Spy:
margin problem

In case the screen shot is not readable, here is a large version:
http://bit.ly/rBvNp8

Something generates a 26 points bottom margin for a header box (probably the control's code, that handles a layout). How can I control this value? I need it to be set to 0.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷港 2024-12-22 05:55:05

为了控制 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>

设置 Margin="10,-2​​,0,0" 就可以了。

In order to control a ContentPresenter's properties one needs to redefine the default template (within a style setter) for the PanoramaItem. In my particular case it is PanoramaItem's style.

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

Setting Margin="10,-2,0,0" does the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文