2014-01-28 50 views
0

想要在擴展視圖右側的標題中對齊文本。 這是我的代碼:WP8擴展視圖標題對齊

<toolkit:ExpanderView HorizontalAlignment="Stretch"> 
    <toolkit:ExpanderView.Header> 
     <TextBlock HorizontalAlignment="Right" Text="test"></TextBlock> 
    </toolkit:ExpanderView.Header> 
</toolkit:ExpanderView> 

但它保持左。爲什麼?

enter image description here

回答

0

我想你可以改變頭的寬度,並使用TextAlignment。就像這個代碼一樣。希望它對你有所幫助。

<toolkit:ExpanderView x:Name="ev" HorizontalAlignment="Stretch"> 
       <toolkit:ExpanderView.Header> 
         <TextBlock Width="{Binding ActualWidth, ElementName=ev}" HorizontalAlignment="Stretch" TextAlignment="Right" Text="test"></TextBlock> 
       </toolkit:ExpanderView.Header> 
      </toolkit:ExpanderView> 
+0

你是說ExpanderView在DataTemplate中?您可以使用LayoutRoot或ContentPanel的Grid而不是ev。 –