我的页面中有一些透视项目,根据应用程序是否处于试用模式,我需要显示或隐藏其中一个PivotItems.直接在XAML或C#中设置PivotItem的可见性仅隐藏PivotItem内的内容,而不是实际的PivotItem本身.我怎么能做到这一点?
在测试中,我尝试了以下两种方法
Page.xaml
<phone:PivotItem x:Name="PivotItem2" Visibility="Collapsed"
Header="2">
...
</<phone:PivotItem>
Run Code Online (Sandbox Code Playgroud)
要么
Page.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
//Check trial state and set PivotItem
if ((Application.Current as App).IsTrial)
{
PivotItem2.Visibility = Visibility.Collapsed;
}
else
{
PivotItem2.Visibility = Visibility.Visible;
}
}
Run Code Online (Sandbox Code Playgroud) 我想在PivotItem控件中设置字体的大小.显式设置PivotItem FontSize似乎没有做任何事情,也没有将PivotItem样式设置为"{StaticResource PhoneFontSizeSmall}"我唯一能找到的将改变字体大小的是Pivot控件上的FontSize属性,但这只是更改数据透视表本身的标题文本的大小,但我想更改PivotItem标题文本的大小.
编辑:好的我已经学会了如何使用它<controls:PivotItem.Header>,但我如何使用绑定?例如:
<controls:Pivot x:Name="pvtKey"
Grid.Row="1"
Height="60"
ItemsSource="{Binding Keys}">
<controls:Pivot.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="5"/>
</DataTemplate>
</controls:Pivot.ItemTemplate> </controls:Pivot>
Run Code Online (Sandbox Code Playgroud) 我有一个带有Pivot和3个PivotItems的应用程序.每个PivotItem都有自己的DataContext,DataContext有一个名为IsLoading的属性.
可以将SystemTray.ProgressIndicator IsVisible属性绑定到选定的pivotitem DataContext.IsLoading属性?
这是我尝试过的:
<shell:SystemTray.ProgressIndicator>
<shell:ProgressIndicator
IsVisible="{Binding ElementName=pivot, Path=SelectedItem.DataContext.IsLoading}" />
</shell:SystemTray.ProgressIndicator>
<Grid Background="Transparent">
<controls:Pivot x:Name="pivot">
<controls:PivotItem Header="pivot item"
Margin="0,28,24,0"
DataContext="{Binding DCOne}" />
<controls:PivotItem Header="pivot item"
Margin="0,28,24,0"
DataContext="{Binding DCTwo}" />
<controls:PivotItem Header="pivot item"
Margin="0,28,24,0"
DataContext="{Binding DCThree}" />
</Grid>
Run Code Online (Sandbox Code Playgroud) 我的枢轴控制的造型有一个奇怪的问题.我在Expression Blend中编辑了默认模板的副本,因为我想删除整个标题.
适应的风格:
<Style x:Key="PivotWithoutHeader" TargetType="phone:Pivot">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<Grid/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="phone:Pivot">
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Background="{TemplateBinding Background}" Grid.RowSpan="3"/>
<!--<ContentControl ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" HorizontalAlignment="Left" Margin="24,17,0,-7" Style="{StaticResource PivotTitleStyle}"/>-->
<Primitives:PivotHeadersControl x:Name="HeadersListElement" Grid.Row="1"/>
<ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" Grid.Row="2"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
而我的风格用法:
<phone:Pivot Grid.Row="1" x:Name="Objects" ItemsSource="{Binding Profiles}"
Style="{StaticResource PivotWithoutHeader}">
<phone:Pivot.ItemContainerStyle> …Run Code Online (Sandbox Code Playgroud) 我有一个3 PivotItem秒的应用程序和一个ApplicationBar.我想隐藏ApplicationBar在PivotItem第2和第3选择,并显示ApplicationBar首当PivotItem选择.
我正在开发一个Windows手机应用程序.我添加了样式Pivot Item.
<phone:PhoneApplicationPage.Resources>
<Style TargetType="phone:Pivot">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<Grid/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="phone:Pivot">
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Background="#D62429" CacheMode="BitmapCache" Grid.RowSpan="2" />
<Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache"
Grid.Row="2" />
<ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}"
Content="{TemplateBinding Title}" Margin="25,10,0,0" />
<Primitives:PivotHeadersControl x:Name="HeadersListElement"
Grid.Row="1" />
<ItemsPresenter x:Name="PivotItemPresenter"
Margin="{TemplateBinding Padding}" Grid.Row="2"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</phone:PhoneApplicationPage.Resources>
Run Code Online (Sandbox Code Playgroud)
它表现得像这样 …
pivot windows-phone-7 windows-phone-7.1 pivotitem windows-phone-8