Themes - RecognizesAccessKey Missing in Buttons

Mar 26, 2009 at 10:18 PM
When I apply whatever theme provided in the futures Buttons display the underscore, the RecognizesAccessKey is Missing.

I miss another issue to buttons and is a design for defaulted buttons, in order to change the border or some other color when the button is the defaulted button.

Tabs work well, but bureaublack, bureaublue and whistlerblue doesn´t strecht the content to the tab. If I add a DataGrid it is placed Vertically in the Center of the tab and only filled rows are displayed.

thanks,
Toni
Apr 22, 2009 at 8:36 PM

I just wanted to add to the op's question.  This is the first I have been able to find of someone posting about the same issue I am having.  I am using the latest download of the WPF themes.  I am using them in VS 2008, SP1.  So far BureauBlue and WhistlerBlue are showing the same issue with the underscore.  The problem is that the underscore shows as text in the button ONLY when you run the application. 

To recreate the problem, I have attached the sample code that shows the problem.  I have NOT included the theme xaml.

A separate issue is with the BureauBlue theme that when you enable a button that was disabled, the text is not returned to the enabled state.  I have tried a few things to make the text return back to the enabled color and have not got it yet.  The WhistlerBlue theme does not have this second issue, but so far trying to compare the two themes has not helped me.

Thanks for any help or insights.

Window1.xaml

<Window x:Class="WpfApplicationTestThemes.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" WindowStartupLocation="CenterScreen" >
    <Grid>
        <Button Height="23" Margin="22,12,0,0" Name="button1" VerticalAlignment="Top" Click="button1_Click" HorizontalAlignment="Left" Width="74">_Button</Button>
        <Button Height="23" Margin="20,41,0,0" Name="button2" VerticalAlignment="Top" IsEnabled="False" HorizontalAlignment="Left" Width="76">Button</Button>
        <GroupBox Header="groupBox1" Margin="14,105,64,57" Name="groupBox1">
            <Grid>
                <Button Margin="66,33,46,16" Name="button3">Button</Button>
            </Grid>
        </GroupBox>
    </Grid>
</Window>

Window1.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplicationTestThemes
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            button2.IsEnabled = !button2.IsEnabled;
        }
    }
}

App.xaml

<Application x:Class="WpfApplicationTestThemes.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="Window1.xaml">
    <Application.Resources>
        <ResourceDictionary Source="WhistlerBlue.xaml"/>
    </Application.Resources>
</Application>

Apr 23, 2009 at 2:51 PM
Edited Apr 23, 2009 at 3:25 PM

I found the solution to the the underscore issue. 

Put RecognizesAcessKey="True" in the ContentPresenter section of the button.

*update:  This worked on WhistlerBlue, not on BureauBlue theme.

Apr 23, 2009 at 4:30 PM
Edited Apr 23, 2009 at 4:31 PM
Fixed it.

In BureauBlue theme remove the following from the button style

                  <Storyboard x:Key="DisabledOn">
                            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00.1000000" Value="{x:Static Visibility.Visible}" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00.1000000" Value="{x:Static Visibility.Visible}" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00.1000000" Value="{x:Static Visibility.Collapsed}" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>

Then remove the following from the trigger for IsEnabled false:

                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource DisabledOn}" />
                            </Trigger.EnterActions>

My access key code now works.

I was also getting "Cannot use a DependencyObject that belongs to a different thread than its parent Freezable" with this theme that I was NOT getting with the WhistlerBlue theme that is now resolved.

*editing spelling mistakes

Apr 23, 2009 at 5:32 PM
Thaks for your work,

At first I put the RecognizesAcessKey="True" in the ContentPresenter as you do, but I didn´t realize that the underscore appeared again when the button was disabled in Bureau and Whistler Themes.

I have found some other bugs in these themes so I decided to put them away from my theme collection, till I have time to work on them. Two of these bugs are very important. The first I have posted it before, I don´t like a theme that minimizes the size of its content. The second is that comboboxes do not work with Entity Databases, when you display the form, the combo appears to work properly but when the combobox list is opened, data is not displayed, only the class of the entity is repeated for each row.

If anybody has found this bugs and managed them, I would appreciate any help or insights.

Thanks in advance.
Apr 24, 2009 at 1:19 AM

I will keep an eye out for the combobox issue, though I have not experienced a problem with setting the combobox's ItemSource property to a list of custom objects.

Just to be concise, the issue was the _ as an access key was not working correctly with WhistlerBlue even with the addition of RecognizesAcessKey until I deleted the above code.

 

Jun 1, 2009 at 12:54 PM

Hello again,

I have corrected a couple of bugs.

The RecognizesAccessKey issue when Disabled in WhistlerBlue:

Thia control should be removed from the template :

<TextBlock Panel.ZIndex="1" x:Name="DisabledOverlay" Text="{TemplateBinding Content}" Foreground="#FF969696" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed"/>

and the trigger should be:

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<Trigger Property="IsEnabled" Value="false">

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

<Setter Property="Visibility" TargetName="DisabledVisualElement" Value="Visible"/>

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

</Trigger>

The combobox issue with Entity List in WhistlerBlue:

In the comboboxitem contentTemplate this Lines shoul be removed:

Jun 15, 2009 at 5:55 PM

Anyone know how to fix the checkbox problem in BureauBlue?  My checkboxes appear disabled, even when they aren't.  You can actually check them, but they are greyed out.  I've been working on a fix by creating "DisabledOff" and triggering it on "IsEnabled" Value = "true" on the checkbox, but it isn't working.   The result I have now is that the checkboxes all appear enabled, whether they are or not.  So I've got:

 

 

 

 

 

 

 

 

 

 

 

 

<!--Pre-existing code-->

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

<

</font></font><font size="2" color="#0000ff">

 

</font>

Trigger Property="IsEnabled" Value="false">

<Trigger.EnterActions>

 

 

 

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<BeginStoryboard Storyboard="{StaticResource DisabledOn}" /><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</Trigger.EnterActions><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" /><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</Trigger><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

 

<!--start of the repair-->

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<Trigger Property="IsEnabled" Value="true">

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<Trigger.EnterActions>

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<BeginStoryboard Storyboard="{StaticResource DisabledOff}" />

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

</Trigger.EnterActions>

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

 

<!-- what to put here???? />-->

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

</Trigger>

AND.......

 

 

 

 

<!--Pre-existing stuff-->

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

<

</font></font><font size="2" color="#0000ff">

 

</font>

Storyboard x:Key="DisabledOn">

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty ="(UIElement.Visibility)"><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<DiscreteObjectKeyFrame KeyTime="00:00:00.1000000" Value="{x:Static Visibility.Visible}" /><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</ObjectAnimationUsingKeyFrames><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</Storyboard><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

 

<!--adding this to try to fix-->

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<Storyboard x:Key="DisabledOff">

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Visibility)">

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<DiscreteObjectKeyFrame KeyTime="00:00:00.1000000" Value="{x:Static Visibility.Collapsed}" />

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

</ObjectAnimationUsingKeyFrames>

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

</Storyboard>

Jun 16, 2009 at 9:22 AM

Hi,

You should change the IsChecked Trigger. It should be:

                        <Trigger Property="IsChecked" Value="true">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource CheckedOff}" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource CheckedOn}" />
                            </Trigger.EnterActions>
                        </Trigger>

You shoud change it for CheckButton and RadioButton in almost all the themes.