【问题标题】:unable to set width height property of Teaching tip in UWP [closed]无法在 UWP 中设置教学提示的宽度高度属性 [关闭]
【发布时间】:2020-04-19 20:56:46
【问题描述】:

您好,我正在尝试设置 UWP 教学提示类的宽度、高度。 但它不起作用。任何人都知道发生了什么。这会有所帮助。

【问题讨论】:

标签: uwp windows-community-toolkit


【解决方案1】:

无法在 UWP 中设置教学提示的宽高属性

TeachingTip控件会根据内容大小自动设置大小,如果要修改它,请在Content属性中添加一个元素并设置相应大小的元素。

<controls:TeachingTip         
    x:Name="ToggleThemeTeachingTip1"
    Title="Change themes without hassle"
    Subtitle="It's easier than ever to see control samples in both light and dark theme!"
    Target="{x:Bind ThemeButton}"
    >
    <controls:TeachingTip.IconSource>
        <controls:SymbolIconSource Symbol="Refresh" />
    </controls:TeachingTip.IconSource>
    <controls:TeachingTip.Content>
        <StackPanel Height="300">
            <TextBlock Text="t's easier than ever to see control samples in both light and dark theme!" TextWrapping="Wrap"/>
        </StackPanel>
    </controls:TeachingTip.Content>
</controls:TeachingTip>

请注意TeachingTip 控件的默认设置有大小限制,更多请参考this。 这些最大值的默认值。和最小尺寸应该被覆盖,以便基于内容的动态尺寸可以工作:

<x:Double x:Key="TeachingTipMinHeight">40</x:Double>
<x:Double x:Key="TeachingTipMaxHeight">520</x:Double>
<x:Double x:Key="TeachingTipMinWidth">320</x:Double>
<x:Double x:Key="TeachingTipMaxWidth">336</x:Double>

【讨论】:

  • 嗨,Nico,我已经访问了给定的链接,指定的最小宽度的问题是 320,我的项目中有一个场景,我需要动态设置它。所以有什么办法我们可以在页面中覆盖并使用较小的宽度,例如 10,20 等
  • 请尝试将&lt;x:Double x:Key="TeachingTipMinWidth"&gt;your width&lt;/x:Double&gt;添加到应用的应用资源字典中
  • 它的作品感谢 Nico 你拯救了我的一天
  • @Nico:这也适用于 WinUI 中的“TeachingTip”控件(我想这是基于 USW 版本的控件)
猜你喜欢
  • 1970-01-01
  • 2016-10-08
  • 2017-11-03
  • 2011-08-17
  • 2013-02-09
  • 1970-01-01
  • 1970-01-01
  • 2020-08-06
  • 1970-01-01
相关资源
最近更新 更多