1

I'm trying to horizontal strech button inside ListView, but my xaaml code doesn't work:

        <ListView Grid.Row="2" ItemsSource="{Binding Path=Items}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Button Grid.Row="2" Background="White" BorderThickness="4,0,0,1" BorderBrush="#8c0095" Margin="32,-3,32,17" Padding="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">

                            <TextBlock Text="{Binding Name}" Foreground="#8c0095" FontSize="20" Margin="15,1,0,10" FontWeight="Medium" />

                    </Button>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

How can I solve this?

Earlgray
  • 647
  • 1
  • 8
  • 31
  • You have a 32unit margin left and right is that intentional? Just asking cos that's probably why you think button aint stretching. – Viv Mar 11 '13 at 23:05
  • Yes it is intentional, but if I delete that margin, button ain't strech too. – Earlgray Mar 11 '13 at 23:10
  • 2
    you want the button to stretch all the way across the ListView ? Does this get you want you want: http://stackoverflow.com/questions/15067309/listviewitem-wont-stretch-to-the-width-of-a-listview – Jim O'Neil Mar 12 '13 at 05:55

0 Answers0