Here is XAML for a window containing two buttons, both disabled. One of them has been made multiline by setting the button's content to a StackPanel containing two TextBlocks.
<Window x:Class="MainWindow" 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" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Button Grid.Column="0" Content="Single line" IsEnabled="False" /> <Button Grid.Column="1" IsEnabled="False"> <StackPanel> <TextBlock HorizontalAlignment="Center">Double</TextBlock> <TextBlock HorizontalAlignment="Center">Line</TextBlock> </StackPanel> </Button> </Grid> </Window>
Here is what it looks like on my machine when I run the program:
Why is the text on one button different to the other? On the single-line button the text is a more faded colour. I want the text to look the same on both buttons.
I want to do this purely in XAML.
The text must be centered within the button as shown (automatically by the framework, without me having to manually space it out by inserting nonbreaking spaces or the like). In particular, solutions that cause the left-hand edge of the "L" in "Line" to line up vertically with the left-hand edge of the "D" in "Double" are not acceptable. (So using the Content attribute in the second button but embedding a
in the text is not a viable solution, since it causes this effect.)
I don't want to have to paste a load of style information into my XAML. Solutions that involve pasting in a definition of what a disabled button looks like are not acceptable; I want both buttons to just look like whatever a disabled button should look like by default on my operating system, without having to explicitly specify what that means. Declarative solutions, that involve directing XAML to use whatever style would ordinarily be applied to text in a disabled button - these are fine, so long as I don't have to explicitly specify what that style looks like.