uwp 自适应 gridview 呈现第一个元素错误

touseefbsb

我使用AdaptiveGridViewUWP社区工具第一个项目显示非常错误,所有其他项目都显示得很好。

在下图中,第 1 个项目的文件夹图像比其他项目大。

看到第一个项目周围有红线

XAML

<Style TargetType="controls:AdaptiveGridView" x:Key="MainAdaptiveStyle">
    <Setter Property="SelectionMode" Value="None"/>
    <Setter Property="StretchContentForSingleRow" Value="False"/>
    <Setter Property="DesiredWidth" Value="220"/>
    <Setter Property="IsItemClickEnabled" Value="True"/>
    <Setter Property="animations:ReorderGridAnimation.Duration" Value="400"/>
</Style>


<PivotItem Header="Folders">
    <controls:AdaptiveGridView Name="FoldersLibraryGridView"
                               Style="{StaticResource MainAdaptiveStyle}"
                               ItemsSource="{x:Bind ViewModel.Folders}">
        <controls:AdaptiveGridView.ItemTemplate>
            <DataTemplate  x:DataType="data:FolderItem">
                <userTemplates:FolderTemplate />
            </DataTemplate>
        </controls:AdaptiveGridView.ItemTemplate>
    </controls:AdaptiveGridView>
</PivotItem>

<.... 下面是使用 DataTemplate 的用户控件,称为FolderTemplate ...>

<Grid >
    <Grid.Resources>
        <Style TargetType="Image" x:Key="ThumbImageStyle" >
            <Setter Property="Stretch" Value="UniformToFill"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="8"/>
        </Style>
    </Grid.Resources>
    <Grid.RowDefinitions>
        <RowDefinition Height="8*"/>
        <RowDefinition Height="3*"/>
    </Grid.RowDefinitions>
    <Border x:Name="ThumbImage" Grid.Row="0">
        <Border.Background>
            <SolidColorBrush Color="{ThemeResource SystemAccentColor}" Opacity="0.5"/>
        </Border.Background>
        <Image  Source="ms-appx:///Assets/FolderIcon.png"    

                Style="{StaticResource ThumbImageStyle}"
                />
    </Border>
    <Border Background="{ThemeResource SystemAltHighColor}" Grid.Row="1" Padding="8,0,4,0">
        <TextBlock  Text="{x:Bind FolderItem.MyFolder.DisplayName}"
                    Style="{StaticResource GridViewVideoName}"/>
    </Border>
</Grid>

UPDATE,你可以在下面的图片中,市场红线看到,每个项目的右侧褪色的文件夹名称文本块结束,其中,只有当ItemHeight明确的设置发生这种情况ApativeGridView

褪色的问题

贾斯汀 XL

I think the fix is simple. First have a look at the description of this control on GitHub -

/// <remarks>
/// The number and the width of items are calculated based on the
/// screen resolution in order to fully leverage the available screen space. The property ItemsHeight define
/// the items fixed height and the property DesiredWidth sets the minimum width for the elements to add a
/// new column.</remarks>

I believe ItemsHeight is a typo there. It really should be ItemHeight. You just need to specify it (e.g. <controls:AdaptiveGridView ItemHeight="280" ... /> and the problem should go away.


Update

Your second issue is related to the DropShadowPanel in the toolkit. If you resize the window a bit you will notice that the shadows then render properly.

I had a look at the default style of the control and the HorizontalContentAlignment property is set to Left initially. So it looks like the control doesn't properly resize its inner shadow component when the size is changed.

But since you have already got a local style, you can just set it to Stretch and the issue should go away.

<Style TargetType="controls:DropShadowPanel"
       x:Key="MainDropShadow">
    <Setter Property="HorizontalContentAlignment"
            Value="Stretch" />

Update 2

OK, so here is the reason why initially the shadow is not stretching -

The shadow size is calculated based on the Content of the DropShadowPanel control, but the shadow only monitors the SizeChanged event of the control to update its size.

What's happening in your case is that your Grid (direct child of the DropShadowPanel control) was initially arranged with a smaller size, then the shadow size was set, and then when the size of your Grid updates, because the size of DropShadowPanel is still with the same size, no SizeChanged will be invoked, hence the shadow size is not re-calculated. If you have the toolkit source code, you should be able to simply switch to monitor the SizeChanged of the Content instead and the problem should go away.

当您设置HorizontalContentAlignment为 时Stretch,您实际上是在说“孩子应该具有与父母相同的大小”。因此,当最初调整阴影大小时,您Grid的大小已经与其父对象的大小相同。但我觉得他们一定是Left出于某种原因使用的,这应该只是对您的情况的临时解决方案。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

UWP 中的自适应 AutoSuggestBox

来自分类Dev

Windows 10 UWP两个自适应触发器未按预期工作

来自分类Dev

如何在 uwp 中编写这样的自动自适应面板?

来自分类Dev

MATLAB中的自适应椭圆结构元素

来自分类Dev

4个DIV的自适应设计

来自分类Dev

小组中的自适应卡中最多只能显示6个自适应动作

来自分类Dev

自适应卡未在Teams移动应用上呈现

来自分类Dev

缺少错误-PayPal自适应付款API错误

来自分类Dev

用自适应卡模板重复元素

来自分类Dev

如何解决此自适应导航错误?

来自分类Dev

自适应链式贝宝付款::错误550001

来自分类Dev

NavigationView中的UWP ListView,仅呈现第一个子级

来自分类Dev

GridView UWP高度中的GridView

来自分类Dev

我对Paypal自适应API有一个奇怪的问题

来自分类Dev

当卡片有 5 个以上的动作时,自适应卡片不会在 Spfx 上呈现

来自分类Dev

UWP中的GridView

来自分类Dev

UWP GridView表

来自分类Dev

UWP GridView上在“ {”之后使用的“ TemplateBinding”必须是标记扩展”错误

来自分类Dev

当处于非模态状态时,展开搜索不会取消自适应弹出窗口的呈现

来自分类Dev

Facebook Page插件-动态重新呈现/更改宽度(自适应/ RWD)

来自分类Dev

无法使用 Bot Framework SDK v4 在 MS Teams 中呈现自适应卡片

来自分类Dev

我可以在另一个 ListView 的 HeaderItem 中添加 ListView 或 GridView 吗?[UWP]

来自分类Dev

如何在PyQt5中捕获libpng错误错误的自适应滤波器

来自分类Dev

PayPal自适应付款错误您无权隐式执行此付款

来自分类Dev

贝宝沙盒500代理错误-贝宝自适应

来自分类Dev

PayPal自适应付款错误您无权隐式执行此付款

来自分类Dev

如何创建具有可滚动效果的自适应一页WordPress主题?

来自分类Dev

从两列到一列的自适应4格网格

来自分类Dev

r-一组观测值在时间间隔中的自适应划分

Related 相关文章

  1. 1

    UWP 中的自适应 AutoSuggestBox

  2. 2

    Windows 10 UWP两个自适应触发器未按预期工作

  3. 3

    如何在 uwp 中编写这样的自动自适应面板?

  4. 4

    MATLAB中的自适应椭圆结构元素

  5. 5

    4个DIV的自适应设计

  6. 6

    小组中的自适应卡中最多只能显示6个自适应动作

  7. 7

    自适应卡未在Teams移动应用上呈现

  8. 8

    缺少错误-PayPal自适应付款API错误

  9. 9

    用自适应卡模板重复元素

  10. 10

    如何解决此自适应导航错误?

  11. 11

    自适应链式贝宝付款::错误550001

  12. 12

    NavigationView中的UWP ListView,仅呈现第一个子级

  13. 13

    GridView UWP高度中的GridView

  14. 14

    我对Paypal自适应API有一个奇怪的问题

  15. 15

    当卡片有 5 个以上的动作时,自适应卡片不会在 Spfx 上呈现

  16. 16

    UWP中的GridView

  17. 17

    UWP GridView表

  18. 18

    UWP GridView上在“ {”之后使用的“ TemplateBinding”必须是标记扩展”错误

  19. 19

    当处于非模态状态时,展开搜索不会取消自适应弹出窗口的呈现

  20. 20

    Facebook Page插件-动态重新呈现/更改宽度(自适应/ RWD)

  21. 21

    无法使用 Bot Framework SDK v4 在 MS Teams 中呈现自适应卡片

  22. 22

    我可以在另一个 ListView 的 HeaderItem 中添加 ListView 或 GridView 吗?[UWP]

  23. 23

    如何在PyQt5中捕获libpng错误错误的自适应滤波器

  24. 24

    PayPal自适应付款错误您无权隐式执行此付款

  25. 25

    贝宝沙盒500代理错误-贝宝自适应

  26. 26

    PayPal自适应付款错误您无权隐式执行此付款

  27. 27

    如何创建具有可滚动效果的自适应一页WordPress主题?

  28. 28

    从两列到一列的自适应4格网格

  29. 29

    r-一组观测值在时间间隔中的自适应划分

热门标签

归档