Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Regarding your annoyance at the sizing of buttons, this is something that seems to be targeted at the designer in the designer/developer workflow, while you're clearly working on the developer portion. For the sake of development, I always apply a few styles in my App.xaml to ensure somewhat better button sizing. For example, in the application tag in your app.xaml file:</p> <pre><code>&lt;Application.Resources&gt; &lt;Style TargetType="Button"&gt; &lt;Setter Property="MinWidth" Value="60" /&gt; &lt;Setter Property="MinHeight" Value="23" /&gt; &lt;Setter Property="Margin" Value="3" /&gt; &lt;/Style&gt; &lt;/Application.Resources&gt; </code></pre> <p>Regarding your actual question:</p> <p>The problem is that your DockPanel is stretching to the width of the text and the button will naturally expand to fill the available area. If you want the quick and dirty solution you can do something like:</p> <pre><code>&lt;DockPanel HorizontalAlignment="Left"&gt; &lt;Button x:Name="ButtonFavorite" DockPanel.Dock="Top" Content="Customers" Margin="10" Width="Auto" MaxWidth="100" Click="ButtonFavorite_Click"&gt; &lt;/Button&gt; &lt;/DockPanel&gt; </code></pre> <p>Note the MaxWidth. If you want a more composable result, isolate your button in another panel. (I'm using a stackpanel because I believe someone else already used a grid in their example):</p> <pre><code>&lt;DockPanel HorizontalAlignment="Left"&gt; &lt;StackPanel DockPanel.Dock="Top" Orientation="Horizontal"&gt; &lt;Button x:Name="ButtonFavorite" Content="Customers" Margin="10" Width="Auto" Click="ButtonFavorite_Click" /&gt; &lt;/StackPanel&gt; &lt;TextBlock DockPanel.Dock="Top" Text="this is a long text which makes the button stretch across the window, if this text is just a couple words, the button will be smaller, and this drives me up the wall" Margin="10" TextWrapping="Wrap" /&gt; &lt;/DockPanel&gt; </code></pre> <p>I like the StackPanel in this case because I find myself using it to create the horizontal "bar" of buttons along the bottom of a Form- err- Window in the right corner.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload