简体   繁体   English

如何从Windows Build 1903中提供的Xaml控件禁用默认的Shadow?

[英]How to disable the default Shadow from Xaml controls which is provided in Windows Build 1903?

So, Windows build 1903 sdk has applied a default "Shadow" on certain xaml controls, as can be seen from the list. 因此,从列表中可以看出,Windows内部版本1903 sdk已在某些xaml控件上应用了默认的“阴影”。 I am using CommandBar in a project, and the "See more" button has an associated Popup with it, however I find no way to disable the shadow of it. 我在项目中使用CommandBar,并且“查看更多”按钮具有关联的Popup,但是我找不到禁用它的阴影的方法。 This shadow does not show in any other previous windows Builds. 此阴影不会在任何其他以前的Windows版本中显示。 Reference: https://docs.microsoft.com/en-us/windows/uwp/design/layout/depth-shadow 参考: https : //docs.microsoft.com/zh-cn/windows/uwp/design/layout/depth-shadow

In the microsoft's blog post regarding this, they have given out the following code to remove shadow from a flyout like object, however they did not specify any code for removing the shadow from other controls. 在与此有关的Microsoft博客文章中,他们给出了以下代码以从弹出对象中删除阴影,但是他们未指定任何代码从其他控件中删除阴影。

This particular property in the following code named "IsDefaultShadowEnabled" is only accessible from the FlyoutPresenterStyles, I have tried from other controls, such as GridView, Border, couldn't find it in there. 以下代码中名为“ IsDefaultShadowEnabled”的特定属性只能从FlyoutPresenterStyles访问,而我尝试从其他控件(例如GridView,Border)尝试在其中找不到它。 I tried attaching this flyout with the flyoutbase associated with the command bar. 我尝试将此弹出控件附加到与命令栏关联的flyoutbase上。 but did not help. 但没有帮助。

I added the code for the commandbar I am having the shadow on. 我添加了阴影的命令栏代码。

  <Flyout>
       <Flyout.FlyoutPresenterStyle>
           <Style TargetType="FlyoutPresenter">
               <Setter Property="IsDefaultShadowEnabled" Value="False" />
          </Style>
       </Flyout.FlyoutPresenterStyle>
  </Flyout>



    <CommandBar Background="Yellow" FocusVisualPrimaryThickness="0" FocusVisualSecondaryThickness="0">
        <CommandBar.CommandBarOverflowPresenterStyle>
            <Style TargetType="CommandBarOverflowPresenter">
                <Setter Property="BorderThickness" Value="0"/>
            </Style>
        </CommandBar.CommandBarOverflowPresenterStyle>
        <CommandBar.SecondaryCommands>

            <AppBarButton Label="YELLOW!"/>
            <AppBarButton  Label="YELLOW!"/>
            <AppBarButton  Label="YELLOW!"/>
        </CommandBar.SecondaryCommands>

    </CommandBar>

Can you guys tell me any workaround to fix the shadow issue if there's no direct solution? 如果没有直接的解决方案,你们能告诉我解决阴影问题的任何解决方法吗?

With @ Faywang - MSFT 's advice, the issue was registered in Win UI team's repository, 根据@ Faywang-MSFT的建议,此问题已在Win UI团队的存储库中注册,

Mr. @jevansaks response mentioned of using SDK Build Version 1903 as the Target version , additionally setting the MaxTestedVersion to the version one tested their app on. @jevansaks先生的回应提到使用SDK Build版本1903作为目标版本 ,另外将MaxTestedVersion设置为对其应用程序进行测试的版本。

https://github.com/microsoft/microsoft-ui-xaml/issues/1136 https://github.com/microsoft/microsoft-ui-xaml/issues/1136

In conclusion, to fix Shadows, we need to set Target Version for building app to SDK 1903, however we can set MaxTestedVersion to the version we tested our app on, for instance it can be 1809. 总之,要修复Shadows,我们需要将用于构建应用程序的目标版本设置为SDK 1903,但是我们可以将MaxTestedVersion设置为测试应用程序的版本,例如可以为1809。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM