tags:

views:

49

answers:

2

I am running Windows XP on my computer, and another computer also is running Windows XP.

In my WPF application, I've changed the styles of my buttons to appear as if they are not highlighting when rolled over, clicked, etc.

On my computer, this is the behavior that is occurring. On the other Windows XP system, I am seeing some outlining of the buttons with I roll over them or click.

Any ideas on why this is happening?

EDIT

Here is the Button itself

        <Button Click="Next_Click" Width="100" VerticalAlignment="Center" BorderThickness="0" BorderBrush="Black" Background="Black" IsTabStop="False" DockPanel.Dock="Right" HorizontalAlignment="Left" Height="154" Name="NextOffers">
            <Image Source="Images/offer_right_arrow.jpg" Width="100" Height="154" MaxWidth="100" MaxHeight="154" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="100" MinHeight="154" ></Image>
        </Button>

Also this Style, too.

<Style TargetType="{x:Type ListBoxItem}" x:Key="ListBoxItemStyle">
    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBox_MouseLeftButtonDown"></EventSetter>
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ListBoxItem">
                <Border Name="Border" Padding="0,0,2,0" SnapsToDevicePixels="true">
                    <ContentPresenter />
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsSelected" Value="true">
                        <Setter TargetName="Border" Property="Background" Value="Black"></Setter>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

I don't have a template made for this button, obviously.

I am loading my ResourceDictionaries dynamically in the code behind.

+1  A: 

It sounds like you need a custom control template for your buttons. The default control template for most WPF controls is dependent upon the Windows theme that is selected, so that a button follows the theme whether you're on the Windows Classic theme, Aero, Royale, or whatever. If you want it to look exactly the same no matter what OS or theme the user has chosen, you'll save yourself a lot of headache using a custom control template.

Google "Show me the template" for an app that will give you the control template source (XAML) for each theme. This is a good starting point for creating custom templates.

FMM
+1  A: 

The problem you're seeing is most likely due to the default Button Chrome. You can apply all sorts of styling, but if you leave that Chrome intact, the Windows theme is going to rear its ugly head.

You'll need to recreate the ControlTemplate itself.

Jay
If I use a control template, do I have to explicitly define the click event in the template?
TheGeekYouNeed
No; I've restyled buttons so they don't show OS/theme-specific styles, and I've never had to set up click events. WPF controls are "lookless," but we have the set of controls we do because each has different *behaviour.* So, you might restyle a button to, say, show a video, not because you wanted to show the video but because you wanted the behaviour of a button.
Jay