2011-04-11 71 views
0

我正在開發一個Windows Phone 7應用程序。對齊ListBoxItem中的TextBlock

我想垂直居中一個ListBoxItem內的文本塊。這是我的XAML代碼:

<ListBoxItem x:Name="SingleGameItem" Height="79" Margin="10,5"> 
    <TextBlock HorizontalAlignment="Center" Height="31" Margin="5" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Center" Width="431" TextAlignment="Center"/> 
</ListBoxItem> 

我該怎麼做?

+0

當您使用您發佈的XAML時會發生什麼? – Praetorian 2011-04-11 15:21:43

+0

TextBlock在ListBoxItem的頂部垂直對齊。 – VansFannel 2011-04-11 15:24:51

+0

您是否嘗試過在ListBox或ListBoxItem本身上將'VerticalContentAlignment'設置爲'Center'? – Praetorian 2011-04-11 15:24:51

回答

0

的解決方案是:

<ListBox x:Name="Options" Margin="12,8,8,8" Grid.Row="1"> 
    <ListBoxItem x:Name="SingleGameItem" Height="79" Margin="10,5" VerticalAlignment="Center"> 
     <TextBlock HorizontalAlignment="Center" Height="31" Margin="5" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Center" Width="431" TextAlignment="Center"/> 
    </ListBoxItem> 
</ListBox> 

對不起。