如何制作慢速移动的FlipViewheaders? UWP
How to make FlipView with slow moving headers? UWP
如何制作像截图一样的视图?如果将它拖到下一个项目,header 也会移动,但比内容慢,并且会改变颜色。
FlipView
不提供属性设置header。正如@Archana 所说,您可以使用使用 Pivot
的 Pivot. There is an official sample from GitHub。此示例演示如何在 UWP 应用程序中使用 Pivot
控件。
您可以在PivotItem
中设置Header
。 header 和 item 是关联的,所以当 header 改变时,item 会立即改变。相反,header 会在项目更改时立即更改。据我所知,没有任何方法可以延迟 header.
的出现
您可以更改所选 header 中文本的颜色。您可以将 TextBlock
添加到 PivotItem.Header
的内容中。您可以在 Pivot
.
中添加 SelectionChanged
事件
例如:
<Pivot Name="MyPivot" SelectionChanged="ListView_SelectionChanged">
<PivotItem>
<PivotItem.Header>
<TextBlock Foreground="White" Text="Hello" />
</PivotItem.Header>
<TextBlock>When headers are in 'Dynamic' mode, hovering a mouse over the pivot headers will show mouse flippers for easy tab switching
</TextBlock>
</PivotItem>
<PivotItem>
<PivotItem.Header>
<TextBlock Foreground="White" Text="Keyboard Support" />
</PivotItem.Header>
<TextBlock>
<Run>Pivot now supports the following keyboard behaviors</Run><LineBreak />
<Run> * While the HeaderPanel is focused:</Run><LineBreak />
<Run> * * Left, Right, Ctrl+PgUp, Ctrl+PgDown: Changes the currently selected PivotItem</Run><LineBreak />
<Run> * * Down: Sets focus in the content area</Run><LineBreak />
<Run> * While the Content area is focused:</Run><LineBreak />
<Run> * * Ctrl+PgUp, Ctrl+PgDown: Changes the currently selected PivotItem</Run>
</TextBlock>
</PivotItem>
</Pivot>
在后面的代码中:
private void MyPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (PivotItem pivotItem in MyPivot.Items)
{
if (pivotItem == MyPivot.Items[MyPivot.SelectedIndex])
{
((TextBlock)pivotItem.Header).Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 255));
}
else
{
((TextBlock)pivotItem.Header).Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(115, 123, 120, 130));
}
}
}
如何制作像截图一样的视图?如果将它拖到下一个项目,header 也会移动,但比内容慢,并且会改变颜色。
FlipView
不提供属性设置header。正如@Archana 所说,您可以使用使用 Pivot
的 Pivot. There is an official sample from GitHub。此示例演示如何在 UWP 应用程序中使用 Pivot
控件。
您可以在PivotItem
中设置Header
。 header 和 item 是关联的,所以当 header 改变时,item 会立即改变。相反,header 会在项目更改时立即更改。据我所知,没有任何方法可以延迟 header.
您可以更改所选 header 中文本的颜色。您可以将 TextBlock
添加到 PivotItem.Header
的内容中。您可以在 Pivot
.
SelectionChanged
事件
例如:
<Pivot Name="MyPivot" SelectionChanged="ListView_SelectionChanged">
<PivotItem>
<PivotItem.Header>
<TextBlock Foreground="White" Text="Hello" />
</PivotItem.Header>
<TextBlock>When headers are in 'Dynamic' mode, hovering a mouse over the pivot headers will show mouse flippers for easy tab switching
</TextBlock>
</PivotItem>
<PivotItem>
<PivotItem.Header>
<TextBlock Foreground="White" Text="Keyboard Support" />
</PivotItem.Header>
<TextBlock>
<Run>Pivot now supports the following keyboard behaviors</Run><LineBreak />
<Run> * While the HeaderPanel is focused:</Run><LineBreak />
<Run> * * Left, Right, Ctrl+PgUp, Ctrl+PgDown: Changes the currently selected PivotItem</Run><LineBreak />
<Run> * * Down: Sets focus in the content area</Run><LineBreak />
<Run> * While the Content area is focused:</Run><LineBreak />
<Run> * * Ctrl+PgUp, Ctrl+PgDown: Changes the currently selected PivotItem</Run>
</TextBlock>
</PivotItem>
</Pivot>
在后面的代码中:
private void MyPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (PivotItem pivotItem in MyPivot.Items)
{
if (pivotItem == MyPivot.Items[MyPivot.SelectedIndex])
{
((TextBlock)pivotItem.Header).Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 255));
}
else
{
((TextBlock)pivotItem.Header).Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(115, 123, 120, 130));
}
}
}