[英]Loopingselector not showing after style definition?
I wanna change the border color of LoopingSelector
so I copy the style definition of LoopingSelectorItem
(as listed bleow) from Generic.xaml to my PhoneApplicationPage.Resources
. 我想更改
LoopingSelector
的边框颜色,所以将LoopingSelector
的样式定义(如上所示)从LoopingSelectorItem
复制到我的PhoneApplicationPage.Resources
。 And then change the Fill
of Grid
into Red
. 然后将“
Grid
Fill
”更改为Red
。
Now the problem is that, when I open this app in simulator, the LoopingSelector
does not show up immediately. 现在的问题是,当我在模拟器中打开此应用程序时,
LoopingSelector
不会立即显示。 But as soon as I touch the screen area where the selector should be, it shows up and the border color is what I want. 但是,只要我触摸选择器应位于的屏幕区域,它就会显示出来,并且边框颜色就是我想要的。 This looks like an initialization problem, but I do not know what to do.
这看起来像一个初始化问题,但我不知道该怎么办。 I try to copy this style definition without any change from the original Generic.xaml, the problem still exists.
我尝试复制此样式定义,而不对原始Generic.xaml进行任何更改,问题仍然存在。 Any one can help me with this problem?
有人可以帮助我解决这个问题吗?
<phone:PhoneApplicationPage.Resources>
<Style TargetType="primitives:LoopingSelectorItem">
<Setter Property="Foreground" Value="{StaticResource PhoneSubtleBrush}"/>
<Setter Property="Padding" Value="6"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border x:Name="root" CacheMode="BitmapCache" Background="Transparent" Padding="{TemplateBinding Padding}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Normal" To="Expanded" GeneratedDuration="0:0:0.33" />
<VisualTransition From="Expanded" To="Normal" GeneratedDuration="0:0:0.33" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<VisualState x:Name="Expanded">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Opacity" To="0.8" Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="background" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
<DoubleAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="border" Storyboard.TargetProperty="BorderBrush" Duration="0">
<ObjectAnimationUsingKeyFrames.KeyFrames>
<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent" />
</ObjectAnimationUsingKeyFrames.KeyFrames>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="contentControl" Storyboard.TargetProperty="Foreground" Duration="0">
<ObjectAnimationUsingKeyFrames.KeyFrames>
<DiscreteObjectKeyFrame KeyTime="0" Value="White" />
</ObjectAnimationUsingKeyFrames.KeyFrames>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border.RenderTransform>
<TranslateTransform x:Name="Transform"/>
</Border.RenderTransform>
<Grid>
<Rectangle x:Name="background" Margin="0" Opacity="0" Fill="Red" CacheMode="BitmapCache"/>
<Border x:Name="border" Opacity="0" BorderThickness="3" BorderBrush="{StaticResource PhoneSubtleBrush}">
<ContentControl x:Name="contentControl" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch">
<ContentPresenter x:Name="contentPresenter" CacheMode="BitmapCache"/>
</ContentControl>
</Border>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</phone:PhoneApplicationPage.Resources>
I've just found myself having this exact same problem. 我刚刚发现自己也遇到了同样的问题。 The way I got round it was by taking the LoopingSelector and LoopingSelectorItem code from the Toolkit's source, rename them to CustomLoopingSelector and CustomLoopingSelectorItem.
我的解决方法是从Toolkit的源代码中获取LoopingSelector和LoopingSelectorItem代码,将它们重命名为CustomLoopingSelector和CustomLoopingSelectorItem。 Then in my generic.xaml, but the Toolkit's default style for the LoopingSelector, but then add the style I wanted for the LoopingSelectorItem as the CustomLoopingSelectorItem's default style.
然后在我的generic.xaml中,但将工具箱的默认样式设置为LoopingSelector,然后将我想要的LoopingSelectorItem样式添加为CustomLoopingSelectorItem的默认样式。
This has now given me the style I want, and doesn't blank out when coming back into the page. 现在,这给了我想要的样式,并且在返回页面时不会空白。 Might be worth a try for you.
可能值得您尝试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.