SORU
11 Kasım 2008, Salı


WPF:=Germek, Genislik ve Sol aynı anda uyumlu HorizontalAlignment?

Bu kolay olacak gibi görünüyor ama kafam allak bullak oldu. WPF, yalnızca maksimum genişliği için üst genişliğine, ama uzanan bir TextBox istiyorum. Sorun üst içinde sola dayalı olmasını istiyorum. Bu HorizontalAlignment kullanmak zorunda streç ulaşmak için="Stretch", ama sonra sonuç ortalanır. HorizontalContentAlignment tecrübe ettik ama hiçbir işe yaramıyor.

Nasıl bu mavi metin kutusu penceresi boyutunu büyümek için, 200 piksel maksimum genişlik var mı, sola mı?

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel>  
    <TextBox Background="Azure" Text="Hello" HorizontalAlignment="Stretch" MaxWidth="200" />
  </StackPanel>
</Page>

Bu işin sırrı ne? Teşekkürler!

CEVAP
11 Kasım 2008, Salı


Sol için *3 set*, MaxWidth set ve ana öğe ActualWidth bağlamak Width.

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel Name="Container">   
    <TextBox Background="Azure" 
    Width="{Binding ElementName=Container,Path=ActualWidth}"
    Text="Hello" HorizontalAlignment="Left" MaxWidth="200" />
  </StackPanel>
</Page>

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Dumb Stupid Videos

    Dumb Stupid

    26 Kasım 2013
  • super1988guy

    super1988guy

    9 Aralık 2007
  • UCBerkeley

    UCBerkeley

    3 Mayıs 2006