【问题标题】:How can I put a clickable link in a MessageDialog's text?如何在 MessageDialog 的文本中放置可点击的链接?
【发布时间】:2017-06-21 15:30:36
【问题描述】:

我有这样的 MessageDialog 代码:

MessageDialog dlg = new MessageDialog("None of the images you selected contain location information. You can add your own after downloading http://exifpilot.com/");
await dlg.ShowAsync();

我不想让它像那样显示(带有原始/无聊的文本),我想让链接可点击。是否可以将 HyperlinkBut​​ton 作为其按钮之一嵌入到 MessageDialog 中,或者更好的是,使文本的适当部分可点击/可点击?是否可以使用 XAML 或 HTML 作为文本值来完成此操作,还是几乎不可能?

更新

我已经安装了 Callisto 1.4.0.0 版,它是,但是使用这个 XAML:

<Page
    . . .
    xmlns:Controls="using:Callisto.Controls"
    mc:Ignorable="d">

    <callisto:CustomDialog x:FieldModifier="public" x:Name="GetPhotosetName" 
                       Title="Photoset Name" 
                       Background="Teal" BackButtonVisibility="Visible">
        <StackPanel>
            <TextBlock Margin="0,0,0,8" FontSize="14.6667" FontWeight="SemiLight" TextWrapping="Wrap">
            Enter a name for the photoset you are creating
            </TextBlock>
            <TextBlock Margin="0,0,0,8" FontSize="14.6667" FontWeight="SemiLight" Text="Enter your name for acceptance" />
            <callisto:WatermarkTextBox HorizontalAlignment="Left" Watermark="Enter the photoset name" Width="400" Height="35" />
            <StackPanel Margin="0,20,0,0" HorizontalAlignment="Right" Orientation="Horizontal">
                <Button Content="OK" Width="90" Margin="0,0,20,0" />
                <Button Content="CANCEL" Width="90" Click="DialogCancelClicked" />
            </StackPanel>
        </StackPanel>
    </callisto:CustomDialog>

...我收到几个错误消息,例如“找不到类型 'callisto:CustomDialog'。确认您没有丢失程序集引用并且所有引用的程序集都已构建。”和“命名空间前缀“callisto”未定义。”和“Windows 应用项目不支持CustomDialog。”

更新 2

注意:我将 XAML 更改为 smidgen,来自:

callisto:WatermarkTextBox x:Name="txtbxPhotosetName" HorizontalAlignment="Left" Watermark="Enter the photoset name" Width="400" Height="35" />

...到:

<TextBox x:Name="txtbxPhotosetName" HorizontalAlignment="Left" PlaceholderText="Enter the photoset name" Width="400" Height="35" />

...因为一个警告告诉我,水印功能现在可以通过 PlaceholderText 属性在 TextBoxes 本地使用。

【问题讨论】:

    标签: c# html hyperlink windows-store-apps messagedialog


    【解决方案1】:

    没有。 MessageDialog 不可自定义,但您可以创建自己的控件来模仿 MessageDialog 的外观(以及您的自定义增强功能)。

    有几个可用的统包自定义对话框(例如在 http://callistotoolkit.com/ 中),或者您可以很容易地拼凑出一次性的。最低版本可以是一个弹出窗口,其中包含具有部分透明背景的三行 Grid 和中间行带有超链接的 TextBlock。

    还要考虑 MessageDialog 是否是显示错误而不是内联显示错误消息的正确方法。请参阅Guidelines for Message dialogs 和Choosing the right UI surfaces: Errors。

    --罗伯

    【讨论】:

    • 非常感谢! Callisto 自定义对话框看起来像 JWtDO(虽然我不是医生,但我是博士(后挖洞者))。
    • 您在 xmlns 语句中定义“控件”,然后在定义 ContentDialog 时使用“callisto”作为命名空间
    • 如果我理解正确,那么我可以完全删除“xmlns:Controls="using:Callisto.Controls"”,或者将“callisto:”更改为“Controls”对吗?
    • 第二个:你需要,但是两边要匹配。如果将其声明为“控件”,则需要将其引用为“控件”。如果您想将其称为“Callisto”,则需要将其声明为“Callisto”
    • 在模拟标准 UI 时要小心“相当容易”,想到的事情是高 DPI、分辨率变化、可访问性、输入法,很难进行复杂的自定义UI 就像一个内容丰富且行为正确的对话框。
    猜你喜欢
    • 2022-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    • 2011-05-31
    • 1970-01-01
    相关资源
    最近更新 更多