I have a button template. I want the button text to be multiline, but I have no idea how to set this.
I know I can set this in the xaml where I create the button by adding a text block and using <LineBreak/> but this overrides the TextBlock used by the button template.
E.G: The following would work, but the text block defined replaces the text block used by the template. This is no good.
Code:
<Button Template="{StaticResource MenuButtonTemplate}">
<TextBlock>
Project<LineBreak/>Management
</TextBlock>
</Button>
E.G: The following is my button template:
Code:
<ControlTemplate x:Key="MenuButtonTemplate" TargetType="{x:Type Button}">
<Border Name="MenuButtonBorder"
BorderBrush="Black"
BorderThickness="1"
CornerRadius="3"
Background="Transparent"
TextBlock.Foreground="White"
TextBlock.FontSize="12"
TextBlock.TextAlignment="Center"
Width="80"
Margin="3,3,3,3">
<Grid>
<Rectangle Name="MenuButtonFocusCue"
Visibility="Hidden"
Stroke="LightSteelBlue"
StrokeThickness="1"
SnapsToDevicePixels="True">
</Rectangle>
<ContentPresenter RecognizesAccessKey="True"
Margin="2,2,2,2"
VerticalAlignment="Center">
</ContentPresenter>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="MenuButtonBorder"
Property="Background"
Value="Transparent"/>
<Setter TargetName="MenuButtonBorder"
Property="TextBlock.Foreground"
Value="Yellow"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="MenuButtonBorder"
Property="Background"
Value="Transparent"/>
<Setter TargetName="MenuButtonBorder"
Property="TextBlock.Foreground"
Value="Yellow"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="MenuButtonFocusCue"
Property="Visibility"
Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Any suggestions would be appreciated.
Mike B