I have a List with a DataTempalte that shows the text and a "x" button next to it. I want the "X" btn to be shown at the extreme right, so they all appear in same place. The XML I use is :

<ListBox Name="seiveListBox" ItemsSource="{Binding}" MinWidth="80" Height="120" ScrollViewer.VerticalScrollBarVisibility="Visible" >
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding}" />
                                            <Button Name="delSeiveFromListBtn" Content="X" ToolTip="Delete" Margin="8, 0, 0, 0" Click="delSeiveFromListBtn_Click"></Button>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

I tried adding Grid inpalce of StackPanel, but wasn't successful.

How do I design it or align the "x" in the List to be at extreme right on each item.

link|improve this question

The Grid was right idea. Grid with 2 columns. First should have Width="*" and second - Width="Auto". Also set HorizontalContentAlignment="Stretch" for ListBox – EvAlex 36 mins ago
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.