2012-09-16 4 views
9

は表示されません。 CheckedUncheckedイベントのイベントハンドラを設定してボタンをクリックすると、まずCheckedUncheckedが起動します。ボタンが正しく動作するようです...トグルボタンは、私がこれまでで最も簡単なアプリケーションを持っている任意の状態

私は.NET 4.5にコンパイルしており、Windows 8 RTMを使用しています。

は、ボタンを表示するWindows 8のスタイル(なし「3D」の境界線)に関連したこの振る舞いですか?誰でも確認できますか?

私は私が何を意味するのか表示する画像を作っUPDATE 1

Windows 8 vs Windows 7 toggle button

ご覧のとおり、Windows 8の中でトグルボタンをクリックすると、「何も起こらない」、それは単に「トグル」されません。 これは、ボタンを表示するWindows 8のスタイルに関連するバグ、のようです...

UPDATE:2013年5月30日: 修正プログラムはavalibleです:http://support.microsoft.com/kb/2805222
参照の問題#5
WPFの下で残念ながら、私の問題を解決することはありません:(

+1

まさにあなたは「何も起こらない」とはどういう意味ですか?クリックするとボタンが押されて表示されませんか?それが事実なら、それはあなたが言ったようなウィンドウズ8に関連するものかもしれません。 –

+0

はい...何も起こらないということはどういう意味ですか?ボタンが消えないのですか? – Seva

+0

多分あなたはトグルボタンにサイズを定義する必要があります – Seva

答えて

5

これはWPFで確認された不具合です。修正は製品グループによって考慮される可能性がありますが、 Microsoftサポートにお問い合わせください。

01いくつかのコードがでオフに開始したいすべての人のために
+0

[もう少し前に](https://connect.microsoft.com/VisualStudio/feedback/details/763597/togglebutton-doesnt-show-any-state)誰も私の質問に答えたくないので – GameScripting

4

、私は私のコントロールのスタイルを設定するために使用されるコードを実行できます。

<Application.Resources> 

     <!-- Toogle button fix (includes custom button + toggle button style) --> 
     <Style TargetType="{x:Type Button}"> 
      <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/> 
      <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/> 
      <Setter Property="BorderThickness" Value="1"/> 
      <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> 
      <Setter Property="HorizontalContentAlignment" Value="Center"/> 
      <Setter Property="VerticalContentAlignment" Value="Center"/> 
      <Setter Property="Padding" Value="1"/> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="{x:Type Button}"> 
         <Border BorderThickness="1" BorderBrush="#FFA4A4A4"> 
          <Grid> 
           <Rectangle x:Name="Rectangle_Background" Fill="#FFEDEDED" /> 
           <ContentPresenter x:Name="ContentPresenter_Content" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> 
          </Grid> 
         </Border> 
         <ControlTemplate.Triggers> 
          <Trigger Property="IsEnabled" Value="false"> 
           <Setter TargetName="Rectangle_Background" Property="Fill" Value="#f7f7f7"/> 
           <Setter TargetName="ContentPresenter_Content" Property="Opacity" Value="0.5"/> 
          </Trigger> 
          <Trigger Property="IsMouseOver" Value="True"> 
           <Setter TargetName="Rectangle_Background" Property="Fill" Value="#e0e0e0" /> 
          </Trigger> 
         </ControlTemplate.Triggers> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

     <Style TargetType="{x:Type ToggleButton}"> 
      <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/> 
      <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/> 
      <Setter Property="BorderThickness" Value="1"/> 
      <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> 
      <Setter Property="HorizontalContentAlignment" Value="Center"/> 
      <Setter Property="VerticalContentAlignment" Value="Center"/> 
      <Setter Property="Padding" Value="1"/> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="{x:Type ToggleButton}"> 
         <Border BorderThickness="1" BorderBrush="#FFA4A4A4"> 
          <Grid> 
           <Rectangle x:Name="Rectangle_Background" Fill="#FFEDEDED" /> 
           <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> 
          </Grid> 
         </Border> 
         <ControlTemplate.Triggers> 
          <Trigger Property="IsEnabled" Value="false"> 
           <Setter TargetName="Rectangle_Background" Property="Fill" Value="#ADADAD"/> 
          </Trigger> 
          <Trigger Property="IsMouseOver" Value="True"> 
           <Setter TargetName="Rectangle_Background" Property="Fill" Value="#e0e0e0" /> 
          </Trigger> 
          <Trigger Property="IsChecked" Value="true"> 
           <Setter Property="Fill" TargetName="Rectangle_Background" Value="#bee6fd"/> 
          </Trigger> 
         </ControlTemplate.Triggers> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

    </Application.Resources> 
関連する問題