LibraryContainer in a ScatterViewItem: resizing and background rectangle
Simple one: Want to add a LibraryContainer to a Surface ScatterView. Know I have to add the container inside a ScatterViewItem to get the rotate/move features.. but the SVI adds a rectangle box around the control, and it does not size correctly. Think I'm missing something simple but can't figure it... My current XAML is as follows:
Background="{StaticResource WindowBackground}" AllowDrop="True" > . . .
Any thoughts are appreciated... I've been looking at the how-to samples but the library controls that are shown are static item. (ie they are not movable)...
UPDATE:
I understand what you are saying. It makes sense but does not behave as hoped. Below is an entire sample of theLibraryContainer
. It's empty but shows the odd behaviors I'm getting. Namely: no resizing, a background rectangle I can't rid myself of..
Any suggestions are appreciated.
< s:SurfaceWindow x:Class="SurfaceApplication1.SurfaceWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
Title="Surfac开发者_运维百科eApplication1"
>
< s:SurfaceWindow.Resources>
< ImageBrush x:Key="WindowBackground" Stretch="None" Opacity="0.6" ImageSource="pack://application:,,,/Resources/WindowBackground.jpg"/>
< XmlDataProvider x:Key="MyData" XPath="CoverList" x:Name="xdpList">
</XmlDataProvider>
< !-- Describe teh data grouping and bind to the data above -->
< CollectionViewSource
x:Key="MySourceOfData"
Source="{Binding Source={StaticResource MyData}, XPath=Item}" >
< CollectionViewSource.GroupDescriptions>
< PropertyGroupDescription PropertyName="@Size" />
< /CollectionViewSource.GroupDescriptions>
< /CollectionViewSource>
< DataTemplate x:Key="MyDataTemp">
< Border BorderThickness="1" BorderBrush="White" Margin="3">
< Image Source="{Binding XPath=@Image}"></Image>
< /Border>
</DataTemplate>
</s:SurfaceWindow.Resources>
<Grid Background="{StaticResource WindowBackground}" >
<s:ScatterView>
<s:LibraryContainer Name="MainLibraryContainer"
Width="400" Height="200"
ViewingMode="Bar"
ItemsSource="{Binding Source={StaticResource MySourceOfData}}" CanSwitchViewingMode="False" IsActive="True">
<!-- Provide the view if a stack view select (not in use) -->
<s:LibraryContainer.StackView>
<s:StackView
NormalizedTransitionSize="1,1"
ItemTemplate="{StaticResource MyDataTemp}">
</s:StackView>
</s:LibraryContainer.StackView>
<!-- bar view of the data -->
<s:LibraryContainer.BarView>
<s:BarView
Rows="1"
ItemTemplate="{StaticResource MyDataTemp}">
</s:BarView>
</s:LibraryContainer.BarView>
</s:LibraryContainer>
</s:ScatterView>
</Grid>
</s:SurfaceWindow>
I quess you have to Write a ControlTemplate for the ScatterviewItem and pass the Library Stack in It. Or you Just set the Background of the ScatterviewItem to Transparent which might have the same effect. Because Transparent removes the HitTestvisibility on Non-covered Space.
It's hard to say without seeing the rest of your source code, but generally you don't need to manually wrap your content in an SVI. Just add your control directly to the SV and an SVI will automatically be generated as a container. Move/Resize will work as long as internal controls aren't capturing the contacts first.
精彩评论