tags:

views:

32

answers:

2

When I try this, all the buttons turn blue, but the content isn't set.

<Window.Resources>
    <Style TargetType="{x:Type Button}">
        <Setter Property="Background" Value="Blue"/>       
        <Setter Property="Content" Value="Edit"/>     
    </Style>
</Window.Resources>

Any ideas?

EDIT : This example was indeed somewhat too oversimplified. My problem was in changing styles in runtime, where the color was changing allright, but not the content. The solution for me was not to initialize content in xaml, but in code.

A: 

Works for me (tried it in kaxaml). But black text on a Blue background can be hard to read. You sure its not there?

Mark Heath
same here, it works for me...
Thomas Levesque
quite sure :-) .
Peter
+3  A: 

Remember if you set the content property in Style, but if you give some other content in inline xaml it will not work for example if you use

Sometimes XAML Editor like Blend will put Content="" if you just try to delete the content, it will not remove attribute, you will have to check.

So even if your XAML contains Content="" or your code initializes Content Property to even null or empty string, it will not work.

Akash Kava