Note that there are some explanatory texts on larger screens.

plurals
  1. POtemplated silverlight button not resizing correctly
    text
    copied!<p>I would like to create a UI similar to Visual Studio-s open documents stripe. The main idea is, that I have a listbox, which I fill with the open documents' thumbnails. I have the following Templates applied:</p> <pre><code>&lt;DataTemplate x:Key="ListBoxItemTemplate"&gt; &lt;Grid x:Name="grid" Height="23" d:DesignWidth="100"&gt; &lt;Rectangle x:Name="background" Grid.ColumnSpan="3" Stretch="Fill" Fill="{StaticResource LinearMain02}" Margin="0"/&gt; &lt;TextBlock Text="text" Margin="4,0,25,0" Foreground="{StaticResource SolidBaseBrush}" VerticalAlignment="Center"/&gt; &lt;Button x:Name="button" Style="{StaticResource CloseButtonStyle}" Foreground="{StaticResource SolidStrongBrush}" BorderBrush="{x:Null}" Margin="0,0,4,0" VerticalAlignment="Center" HorizontalAlignment="Right" Width="15" Height="15" BorderThickness="0" Opacity="0"/&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;Style x:Key="CloseButtonStyle" TargetType="Button"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="Button"&gt; &lt;Grid Width="{TemplateBinding Height}" Height="{TemplateBinding Height}"&gt; &lt;Ellipse Stroke="{StaticResource SolidBaseBrush}" Opacity="0"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>The ListBox itself is not much to look at, but here it is:</p> <pre><code>&lt;ListBox Grid.Row="1" x:Name="list_tabs" ItemsSource="{Binding Thumbnails}" SelectedItem="{Binding SelectedThumbnail, Mode=TwoWay}" ItemTemplate="{StaticResource TabListItemTemplate}" BorderBrush="{x:Null}" Padding="0" BorderThickness="0" Background="{StaticResource LinearStrong10}"&gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;toolkit:WrapPanel Orientation="Horizontal" ItemHeight="30"/&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;/ListBox&gt; </code></pre> <p>It seems like it doesn't matter how long the content of the item is, it remains 100px wide. That I want to change, so the item would follow the width of its contents. What did I forget to set?</p>
 

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