2009-08-20 36 views
1

我在處理Surface的軟件時遇到了一個小問題:我有一個綁定的ScatterView,它的項目有一個DataTemplate。我的問題是:如何設置從ItemTemplate創建的ScatterViewItem的寬度和高度?s:ScatterView ItemTemplate - 如何設置高度或寬度?

 <s:ScatterView Name="svMain" Loaded="svMain_Loaded" ItemsSource="{Binding BallsCollection}" > 
     <s:ScatterView.ItemTemplate > 
      <DataTemplate> 
       <DockPanel LastChildFill="True" > 
        <DockPanel.Background> 
         <ImageBrush ImageSource="image\note.png" Stretch="Fill" /> 
        </DockPanel.Background> 
        <TextBox Background="Transparent" DockPanel.Dock="Top" Text="{Binding Path=Message}" 
          IsReadOnly="True" TextWrapping="Wrap"></TextBox> 
       </DockPanel> 
      </DataTemplate> 
     </s:ScatterView.ItemTemplate> 
    </s:ScatterView> 

回答

3

我相信你可以設置通過ItemContainerStyle,像其他ItemsControls,但我不能確定,因爲我沒有表面SDK。

<s:ScatterView.ItemContainerStyle> 
     <Style TargetType="{x:Type s:ScatterViewItem}"> 
      <Setter Property="Width" Value="100"/> 
      <Setter Property="Height" Value="100"/> 
     </Style>    
    </s:ScatterView.ItemContainerStyle> 

您當然也可以使用綁定來代替固定單位。

+0

謝謝,它的工作原理! – 2009-08-22 17:58:39