2015-09-27 52 views
1

我想,这是一个错误。主题变更不会影响Windows Phone 8.1上禁用的控制主题

要重现,请在Windows Phone上以暗色主题启动应用程序。 应用程序启动后,将主题更改为亮起。 然后点击“启用”按钮。 你会看到“Sample”按钮消失。因为它的主题依然黑暗。背后

<Page x:Class="ButtonThemeTest.MainPage" 
     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" 
     Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" 
     mc:Ignorable="d"> 

    <Grid> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="Auto" /> 
     </Grid.RowDefinitions> 
     <Button x:Name="ButtonTest" 
       Content="Sample" 
       IsEnabled="False" /> 
     <Button Grid.Row="1" 
       Click="ButtonBase_OnClick" 
       Content="Enable" /> 
     <Button Grid.Row="2" 
       Click="ButtonBase_OnClick2" 
       Content="Disable" /> 
    </Grid> 
</Page> 

代码:

private void ButtonBase_OnClick(object sender, RoutedEventArgs e) 
{ 
    ButtonTest.IsEnabled = true; 
} 

private void ButtonBase_OnClick2(object sender, RoutedEventArgs e) 
{ 
    ButtonTest.IsEnabled = false; 
} 
+0

你检查按钮的控件模板来看看它的设计不当? – WiredPrairie

+0

按钮的控件模板是默认的 – Dmitry

+0

我试图将按钮的RequestedTemplate更改为Light。但它无法帮助。 – Dmitry

回答

1

我发现的唯一的解决方案是从generic.xaml获得按钮的风格和故事板添加到正常的视觉状态是这样的:

<Storyboard> 
    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
            Storyboard.TargetProperty="Foreground"> 
     <DiscreteObjectKeyFrame KeyTime="0" 
           Value="{ThemeResource PhoneForegroundBrush}" /> 
    </ObjectAnimationUsingKeyFrames> 
    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" 
            Storyboard.TargetProperty="BorderBrush"> 
     <DiscreteObjectKeyFrame KeyTime="0" 
           Value="{ThemeResource PhoneForegroundBrush}" /> 
    </ObjectAnimationUsingKeyFrames> 
    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" 
            Storyboard.TargetProperty="Background"> 
     <DiscreteObjectKeyFrame KeyTime="0" 
           Value="{ThemeResource PhoneBackgroundBrush}" /> 
    </ObjectAnimationUsingKeyFrames> 
</Storyboard> 
0

使用Visual Studio混合组样式的按钮。

+0

我同意,这看起来像是决定,但在这种情况下,设置模板到按钮是不可取的设计。 – Dmitry