C# Textblock未出现在pivot中
我有一个轴项目a,标题上有彩色背景C# Textblock未出现在pivot中,c#,xaml,windows-phone-8,windows-phone,C#,Xaml,Windows Phone 8,Windows Phone,我有一个轴项目a,标题上有彩色背景 <Grid x:Name="LayoutRoot" Background="Transparent"> <Rectangle VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="150" Fill="Red" /> <phone:Pivot > <phone:Pivot.HeaderTemplate>
<Grid x:Name="LayoutRoot" Background="Transparent">
<Rectangle
VerticalAlignment="Top" HorizontalAlignment="Stretch"
Height="150" Fill="Red" />
<phone:Pivot >
<phone:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize=" 25" />
</DataTemplate>
</phone:Pivot.HeaderTemplate>
<phone:PivotItem Header="item1">
<TextBlock Text="Test" />
</phone:PivotItem>
<phone:PivotItem Header="item2">
<Grid/>
</phone:PivotItem>
</phone:Pivot>
</Grid>
问题是TextBlock只出现在红色背景上,但我希望红色背景只包含标题
如何使文本块显示在红色背景下
编辑:
下面是一张显示我的问题的图片:
我希望此“测试”文本位于红色背景下,我希望该背景仅涵盖我的标题“element1”和“element2”使用此文本它将起作用
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<controls:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<controls:PivotItem VerticalAlignment="Top" Height="485" Padding="0" Name="pivotitemRecorder">
<controls:PivotItem.Header >
<Border Margin="-10,20,0,0" Height="70" Width="160" BorderThickness="0" BorderBrush="#FF9666D1" CornerRadius="10" Background="Green">
<Border Width="150" Height="50" Backgroung="Red">
<TextBlock Margin="0,10,0,0" HorizontalAlignment="Center" Text="First" Foreground="White" FontSize="36" FontWeight="Bold" />
</Border>
</Border>
</controls:PivotItem.Header>
</controls:PivotItem>
</controls:Pivot>
</Grid>
试试这个
<Grid x:Name="LayoutRoot" Background="Transparent">
<Rectangle VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="89" Fill="Red" />
<phone:Pivot >
<phone:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize=" 25" />
</DataTemplate>
</phone:Pivot.HeaderTemplate>
<phone:PivotItem Header="item1" Margin="10,51,14,32">
<TextBlock Text="Hello World! This is a test for item1" Height="640" VerticalAlignment="Bottom" />
</phone:PivotItem>
<phone:PivotItem Header="item2" Margin="10,51,14,32">
<TextBlock Text="Hello World! This is another test for item2" Height="640" VerticalAlignment="Bottom" />
</phone:PivotItem>
</phone:Pivot>
</Grid>
我已经对此进行了测试。它不起作用,我有“在PivotItem类型中找不到标题”和“HeaderTemplate”不能为空。我将为您提供其他解决方案。几乎是这样。我添加了另一个与您提供的完全相同的PivotItem,但我希望红色背景覆盖整个矩形,项目标题之间没有任何空白,如果你明白我的意思,如果你不需要任何空白,那么你可以像这样设置边距=“-10,0,0,0”但问题是,当标题的大小发生变化时,我希望标题的大小保持不变,而我只想为标题设置一个重新设置的背景