SORU
8 Mayıs 2009, Cuma


Nasıl yatay Liste tam genişliği streç için bir Liste kutusu ItemTemplate almak için?

Listıtems turuncu arka plan ile Listbox tam genişliği genişletmek istiyorum.

Şu anda sadece Ad Soyad gibi geniş.

Ben her öğe ayarladım: HorizontalAlignment="" Memnuniyetle.

Bu Listboxİtems arka plan kullanıcı mutlak değer koymak istemiyorum bu yüzden Listbox uzanır gibi genişletmek istiyorum.

Ben ListBoxİtems arka plan rengini Liste genişliği dolduracak şekilde ne yapmam gerekiyor?

<Window x:Class="TestListBoxSelectedItemStyle.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TestListBoxSelectedItemStyle"
    Title="Window1" Height="300" Width="300">

    <Window.Resources>
        <local:CustomerViewModel x:Key="TheDataProvider"/>

        <DataTemplate x:Key="CustomerItemTemplate">
            <Border CornerRadius="5" Background="Orange" HorizontalAlignment="Stretch" Padding="5" Margin="3">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Width="Auto">
                    <TextBlock HorizontalAlignment="Stretch">
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}{0} {1}">
                            <Binding Path="FirstName"/>
                            <Binding Path="LastName"/>
                        </MultiBinding>
                    </TextBlock.Text>
                    </TextBlock>
                </StackPanel>
            </Border>
        </DataTemplate>

    </Window.Resources>

    <Grid>
        <ListBox ItemsSource="{Binding Path=GetAllCustomers, Source={StaticResource TheDataProvider}}"
                 ItemTemplate="{StaticResource CustomerItemTemplate}"/>
    </Grid>
</Window>

CEVAP
8 Mayıs 2009, Cuma


Bu yineleniyor eminim, ama aynı cevabı olmayan bir soru bulamıyorum.

Senin Liste için HorizontalContentAlignment="Stretch" ekleyin. Bu hile yapmak gerekir.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Liam Underwood

    Liam Underwo

    19 Mayıs 2009
  • ShotgunSandwichENT

    ShotgunSandw

    3 EKİM 2012
  • sk8ingis4me

    sk8ingis4me

    16 Mart 2006