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.
E.G: The following is my button template:Code:<Button Template="{StaticResource MenuButtonTemplate}"> <TextBlock> Project<LineBreak/>Management </TextBlock> </Button>
Any suggestions would be appreciated.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>
Mike B


Reply With Quote
Bookmarks