Search code examples
c#htmlhyperlinkwindows-store-appsmessagedialog

How can I put a clickable link in a MessageDialog's text?


I have MessageDialog code like this:

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();

Rather than just have it display like that (with raw/boring text), I want to make the link clickable. Is it possible to embed a HyperlinkButton into the MessageDialog as one of its buttons, or better yet, make the appropriate portion of the text clickable/tappable? Can XAML or HTML be used as the text value to accomplish this, or is nigh on to impossible?

UPDATE

I have installed Version 1.4.0.0 of Callisto and it is , but with this 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>

...I get several err msgs, such as "The type 'callisto:CustomDialog' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built." and "The namespace prefix "callisto" is not defined." and "CustomDialog is not supported in a Windows App project."

UPDATE 2

Note: I changed the XAML a smidgen, from:

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

...to:

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

...because of a warning advising me that the watermark functionality is now available natively for TextBoxes via the PlaceholderText property.


Solution

  • No. The MessageDialog is not customisable, but you can create your own control which mimics the look and feel of the MessageDialog (plus your custom enhancements).

    There are several turnkey custom dialogs available (such as in http://callistotoolkit.com/ ) or you can cobble a one-shot pretty easily. A minimum version could be a popup containing a three row Grid with a partially transparent background and the TextBlock with Hyperlink in the centre row.

    Also consider if a MessageDialog is the right way to surface the error rather than showing the error message inline. See Guidelines for Message dialogs and Choosing the right UI surfaces: Errors.

    --Rob