views:

350

answers:

1

I have a small problem while working on software for a Surface: I have a binded ScatterView and its items have a DataTemplate. My question is : how do I set the width and height of the ScatterViewItem that it is created from the 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>
+1  A: 

I believe you can set that through the ItemContainerStyle, like with other ItemsControls, but i'm not certain, as i do not have the Surface SDK.

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

You can of course also use bindings instead fixed units.

Bubblewrap
Thank you, it works!
Radu Poe