---
title: "WPF Button with multiple text elements"  
description: "WPF Button with multiple text elements"  
author: "Anonymous User"  
published: 2013-09-04  
updated: 2013-09-04  
canonical: https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# WPF Button with multiple text elements

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to create buttons for a 10-foot GUI using WPF. Each [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) requires a little more data than just a [single text](https://www.mindstick.com/forum/160908/how-to-concatenate-text-from-multiple-rows-into-a-single-text-string-in-sql-server) [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) and an image, maybe 2-3 [strings](https://www.mindstick.com/forum/161912/explain-the-python-strings) located in different positions and some imagery.

I have tried

```
 <Button
Height="52" HorizontalAlignment="Stretch"
Name="button1" 
Width="407">       
<Button.Content>        <DockPanel
LastChildFill="True" HorizontalAlignment="Stretch">            <TextBlock
Name="textBloczk2" Text="ABC"
TextAlignment="Left"  
DockPanel.Dock="Left"/>           
<TextBlock Name="textBlxock1" Text="CDE"
TextAlignment="Right" DockPanel.Dock="Right"/>       
</DockPanel>       
</Button.Content>    </Button>
```

But no matter which inner [container](https://www.mindstick.com/forum/159610/how-to-connect-a-windows-container-to-a-service-running-on-localhost) I use, the button seems to disregard the [layout](https://www.mindstick.com/articles/12853/android-layout-and-its-type) from the DockPanel and the combined text ends up in the middle of the button. Am I doing [something wrong](https://www.mindstick.com/forum/12790/something-wrong-with-gridview) or should I be using a different outer container ?

## Replies

### Reply by Sumit Kesarwani

Hi Ashish,\

The problem seems to be that the DockPanel's width is so small that the Right and Left panels are the same width as your TextBlocks.

This seems to work as expected (setting the width of the DockPanel):

```
    <Button Height="52" HorizontalAlignment="Stretch" Name="button1"  Width="407">        <Button.Content>            <DockPanel LastChildFill="True" Width="300">                <TextBlock Name="textBloczk1" Text="Left" DockPanel.Dock="Left" />                <TextBlock Name="textBlxock2" Text="Right" DockPanel.Dock="Right" />                <TextBlock Name="textBlxock3" Text="Top" DockPanel.Dock="Top" />                <TextBlock Name="textBlxock4" Text="Bottom" DockPanel.Dock="Bottom" />            </DockPanel>        </Button.Content>    </Button>
```


---

Original Source: https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
