修复了Hub控件中的标头

时间:2014-05-25 21:41:01

标签: c# xaml windows-phone-8.1

如何关闭Windows Phone 8.1中Hub控件中的标题移动? 就像在" MixRadio"应用

我试图找到这样的属性设置,但我没有成功。

    <Hub x:Name="HubControl" HorizontalAlignment="Left" Margin="0,25,0,0" VerticalAlignment="Top" Height="640" Background="Black">
        <Hub.Header>
            <StackPanel>
                <TextBlock FontSize="48" FontFamily="Segoe WP Semibold">
                        <Run FontWeight="Bold" Text="An"/>
                        <Run FontWeight="Normal" Text="App"/>
                </TextBlock>
                <TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="updating mix..."/>
            </StackPanel>
        </Hub.Header>
        <HubSection>
            <DataTemplate>
                <Grid>
                    <TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="1 page"/>
                </Grid>
            </DataTemplate>
        </HubSection>
        <HubSection>
            <DataTemplate>
                <Grid>
                    <TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="2 page"/>
                </Grid>
            </DataTemplate>
        </HubSection>
    </Hub>

第二个问题:如何删除第一个和第二个标题文本之间的空格?

1 个答案:

答案 0 :(得分:6)

1.将标题从Hub中取出,它将是静态的。

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel>
        <TextBlock FontSize="48" FontFamily="Segoe WP Semibold">
            <Run FontWeight="Bold" Text="An"/>
            <Run FontWeight="Normal" Text="App"/>
        </TextBlock>
        <TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="updating mix..."/>
    </StackPanel>
    <Hub x:Name="HubControl" HorizontalAlignment="Left" Margin="0,25,0,0" VerticalAlignment="Stretch" Background="Black"
            Grid.Row="1">
        <HubSection>
            <DataTemplate>
                <Grid>
                    <TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="1 page"/>
                </Grid>
            </DataTemplate>
        </HubSection>
        <HubSection>
            <DataTemplate>
                <Grid>
                    <TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="2 page"/>
                </Grid>
            </DataTemplate>
        </HubSection>
    </Hub>
</Grid>

2.删除保证金(甚至设置负值使其更接近)

<StackPanel>
    <TextBlock FontSize="48" FontFamily="Segoe WP Semibold">
        <Run FontWeight="Bold" Text="An"/>
        <Run FontWeight="Normal" Text="App"/>
    </TextBlock>
    <TextBlock FontSize="18" Margin="0,-4,0,0" FontFamily="Segoe WP Semibold" Text="updating mix..."/>
</StackPanel> 

编辑1:

对于第二部分,您可以使用两个TextBlock而不是Runs。

<StackPanel>
    <StackPanel Orientation="Horizontal">
        <TextBlock FontSize="48" FontFamily="Segoe WP Semibold" FontWeight="Bold" Text="An" />
        <TextBlock FontSize="48" FontFamily="Segoe WP Semibold" FontWeight="Normal" Text="App" />
    </StackPanel>
    <TextBlock FontSize="18" Margin="0,-4,0,0" FontFamily="Segoe WP Semibold" Text="updating mix..."/>
</StackPanel>