2011-05-10 52 views
0

我試圖使用Silverlight擴展器控件,並且擴展器的內容在展開時不會均勻地調整到內容的其餘部分。有任何想法嗎?這是什麼樣子Silverlight Expander Control不會均勻擴展

<Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto" /> 
     <ColumnDefinition Width="*"/> 
    </Grid.ColumnDefinitions> 
    <toolkit:Expander ExpandDirection="Right" Grid.Column="0" IsExpanded="True"> 
     <toolkit:Expander.Header> 
      <TextBlock Text="Title" Foreground="Black" /> 
     </toolkit:Expander.Header> 
     <toolkit:Expander.Content> 
      <Controls:Grid x:Name="LayoutRoot" ShowGridLines="True"> 
       <ContentControl Navigation:ContentArea.AreaName="shellView" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" /> 
       <ContentControl x:Name="loaderView" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" /> 
      </Controls:Grid> 
     </toolkit:Expander.Content> 
    </toolkit:Expander> 
    <ContentControl Grid.Column="1" x:Name="testPage" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" /> 
</Grid> 

結果是擴展顯示可用面積的30%,但我想讓它顯示50%

+0

你能告訴我你膨脹機的風格嗎?謝謝 – 2011-05-10 01:39:49

+0

我只是使用默認值。如果我將樣式設置爲Style =「{x:Null}」,我仍然只能得到大約20-30,對於擴展器,我認爲它是一個預設大小。 – 2011-05-10 03:20:39

回答

0

你已經得到了擴展坐在它的列#1一個2列的網格。列的寬度設置爲自動,而其他列的寬度是*,這意味着它只會佔用它需要的空間(並且給它的子對象拉伸對齊不會覆蓋這個,因爲沒有固定空間擴展成)。

只需去除自動應該解決您的問題,並進行擴展的內容填充空間的50%可用於根格:

<Grid.ColumnDefinitions> 
    <ColumnDefinition /> 
    <ColumnDefinition /> 
</Grid.ColumnDefinitions> 

這就是給每列寬度相等的等價物:

<Grid.ColumnDefinitions> 
    <ColumnDefinition Width="*" /> 
    <ColumnDefinition Width="*" /> 
</Grid.ColumnDefinitions>