无法在 uwp 中更改 flipview 的背景?
Unable to change flipview''s background in uwp?
我发现flipview的背景无法更改...
<Page
x:Class="CoreSocialistValues.Views.ImageGalleryCSV2DetailPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:CoreSocialistValues.Models"
KeyDown="OnKeyDown"
mc:Ignorable="d">
<Page.Resources>
<Storyboard x:Name="showFlipView" Completed="OnShowFlipViewCompleted">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="flipView" BeginTime="0:0:0.5">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="shapeGrid" BeginTime="0:0:0.5">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="previewImage" BeginTime="0:0:0.6">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
<Grid>
<FlipView Background="SeaGreen"
x:Name="flipView"
Visibility="Visible"
FocusVisualPrimaryThickness="1,1,1,1"
ItemsSource="{x:Bind Source}"
SelectedItem="{x:Bind SelectedImage, Mode=TwoWay}">
<FlipView.ItemTemplate>
<DataTemplate x:DataType="models:SampleImage">
<Viewbox StretchDirection="DownOnly">
<Image
x:Name="detailImage"
Stretch="None"
Source="{x:Bind Source, Mode=OneWay}" />
</Viewbox>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
<Grid x:Name="shapeGrid"/>
<Image
x:Name="previewImage"
Style="{StaticResource DetailImageStyle}"
Source="{x:Bind SelectedImage.(models:SampleImage.Source), Mode=OneWay}" />
</Grid>
</Page>
然后我尝试修改了flipview的模板,没有任何反应。
我新建一个项目,flipview的背景可以改....
那么有什么办法可以改变吗?
Please see ImageGalleryCSV2DetailPage, I want to set the background to transparent, so that the whole window background seems blured.
您的 FlipView
设置背景失败的问题是因为您在 /Styles/FlipView.xaml
中为您的 FlipView
设置了自定义样式。在这种样式中,您将 Grid
的背景设置为 'Transparent',它是 FlipView
的 ControlTemplate 中的根面板。当您为 FlipView
设置背景时,它将覆盖背景。这就是设置FlipView
.
时总是看不到背景的原因
您可以像下面这样使用 {TemplateBinding Background}
:
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="FlipView">
<Grid Background="{TemplateBinding Background}"
......
之后,如果您为 FlipView
设置 Background="SeaGreen"
,您会发现效果很好。
然后,你说that the whole window background seems blured
。
要达到这种效果,您需要对背景应用一些 Acrylic brush。
例如,
<FlipView
x:Name="flipView" Background="{StaticResource SystemControlAcrylicWindowBrush}"
......
我发现flipview的背景无法更改...
<Page
x:Class="CoreSocialistValues.Views.ImageGalleryCSV2DetailPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:CoreSocialistValues.Models"
KeyDown="OnKeyDown"
mc:Ignorable="d">
<Page.Resources>
<Storyboard x:Name="showFlipView" Completed="OnShowFlipViewCompleted">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="flipView" BeginTime="0:0:0.5">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="shapeGrid" BeginTime="0:0:0.5">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="previewImage" BeginTime="0:0:0.6">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
<Grid>
<FlipView Background="SeaGreen"
x:Name="flipView"
Visibility="Visible"
FocusVisualPrimaryThickness="1,1,1,1"
ItemsSource="{x:Bind Source}"
SelectedItem="{x:Bind SelectedImage, Mode=TwoWay}">
<FlipView.ItemTemplate>
<DataTemplate x:DataType="models:SampleImage">
<Viewbox StretchDirection="DownOnly">
<Image
x:Name="detailImage"
Stretch="None"
Source="{x:Bind Source, Mode=OneWay}" />
</Viewbox>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
<Grid x:Name="shapeGrid"/>
<Image
x:Name="previewImage"
Style="{StaticResource DetailImageStyle}"
Source="{x:Bind SelectedImage.(models:SampleImage.Source), Mode=OneWay}" />
</Grid>
</Page>
然后我尝试修改了flipview的模板,没有任何反应。
我新建一个项目,flipview的背景可以改....
那么有什么办法可以改变吗?
Please see ImageGalleryCSV2DetailPage, I want to set the background to transparent, so that the whole window background seems blured.
您的 FlipView
设置背景失败的问题是因为您在 /Styles/FlipView.xaml
中为您的 FlipView
设置了自定义样式。在这种样式中,您将 Grid
的背景设置为 'Transparent',它是 FlipView
的 ControlTemplate 中的根面板。当您为 FlipView
设置背景时,它将覆盖背景。这就是设置FlipView
.
您可以像下面这样使用 {TemplateBinding Background}
:
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="FlipView">
<Grid Background="{TemplateBinding Background}"
......
之后,如果您为 FlipView
设置 Background="SeaGreen"
,您会发现效果很好。
然后,你说that the whole window background seems blured
。
要达到这种效果,您需要对背景应用一些 Acrylic brush。
例如,
<FlipView
x:Name="flipView" Background="{StaticResource SystemControlAcrylicWindowBrush}"
......