ScatterViewItem 中的 LibraryContainer:调整大小和背景矩形

发布于 2024-09-05 14:47:47 字数 3052 浏览 6 评论 0原文

简单一:想要将 LibraryContainer 添加到 Surface ScatterView。我知道我必须在 ScatterViewItem 内添加容器才能获得旋转/移动功能。但是 SVI 在控件周围添加了一个矩形框,并且它的大小不正确。我认为我错过了一些简单的东西,但无法弄清楚......我当前的 XAML 如下:

背景=“{StaticResource WindowBackground}” 允许放置=“真”> 。 。 。

任何想法都值得赞赏...我一直在查看操作示例,但显示的库控件是静态项目。 (即它们不可移动)...

更新:
我明白你在说什么。这是有道理的,但表现并不如希望的那样。下面是 LibraryContainer 的完整示例。它是空的,但显示了我遇到的奇怪行为。即:无法调整大小,我无法摆脱背景矩形。

任何建议都表示赞赏。

< 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="SurfaceApplication1"
    >
    < 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>

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 the LibraryContainer. 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="SurfaceApplication1"
    >
    < 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红焚 2024-09-12 14:47:47

我猜你必须为 ScatterviewItem 编写一个 ControlTemplate 并在其中传递库堆栈。或者您只需将 ScatterviewItem 的背景设置为透明,可能会产生相同的效果。因为透明删除了非覆盖空间上的 HitTestvisibility。

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.

空宴 2024-09-12 14:47:47

如果没有看到其余的源代码,很难说,但通常您不需要手动将内容包装在 SVI 中。只需将您的控件直接添加到 SV,SVI 将自动生成为容器。只要内部控制不首先捕获联系人,移动/调整大小就可以工作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文