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

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.

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

Related

Xaml - The name is already defined in this scope

I have defined a "Toggle" textblock inside three buttons. I am getting an error that the name "Toggle" Is already defined in the innermost scope of the second and third buttons.
Shouldn't they not be defined in the same scope? It seems they are...
If this is not the way to do it, how can one simply define similar items (Similar to how there can be an id property in css) so one can access the inside of each button via one same identifier in the code behind?
<Button Name="OutputButton" Margin="5" Width="150" Click="OutputToggle_Click" TabIndex="0" HorizontalAlignment="Center">
<TextBlock Name="OutputText" HorizontalAlignment="Center">RF
<TextBlock Name="Toggle" HorizontalAlignment="Left"></TextBlock>
</TextBlock>
</Button>
<Button Name="ModulationButton" Margin="5" Width="Auto" HorizontalAlignment="Left" Click="ModulationToggle_Click" IsEnabled="False" TabIndex="0">
<TextBlock Name="ModulationToggleText" Margin="3">Load Waveform to enable MOD
<TextBlock Name="Toggle"></TextBlock>
</TextBlock>
</Button>
<Button Name="LOSharingButton" Margin="5" Width="150" HorizontalAlignment="Left" Click="AutomaticLOSharingButton_Click">
<TextBlock Name="LOSharingText">LO Sharing
<TextBlock Name="Toggle"></TextBlock>
</TextBlock>
</Button>
The answer to this is to use the tag property of a textblock. This is very similar to the id property in css, but takes a little more effort to find.

WPF Button Font Awesome

I want to Add an Icon and then Aside the Button text, But when I add the fontAwesome Icon the text disapears, here my Button WPF code:
<Button fa:Awesome.Content="Adjust" Content="My Text" Background="#23282D" Foreground="#F1F1F1" FontSize="16" HorizontalContentAlignment="Left" Padding="10" BorderThickness="0" Height="44" />
The Icon is here but the Text not, When I remove the Icon the text comes back again. I tried to play with Alignment and Searching here and on other Forums but can't figure out why this not work. Any ideas what I'm doing wrong?
The simplest way is to set the content of the button to a container (e.g. Grid or StackPanel) containing a TextBlock for the caption and an ImageAwesome control for the icon, setting the appropriate properties of each control as required.
<Button>
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="Adjust" />
<TextBlock Text="My Text" />
</StackPanel>
</Button>

Settings screen for app is throwing an exception

I was trying to use the settings flyout in phone 8.1 runtime to produce a settings screen for an app. However the compiler is throwing an error and I dont no why. This would have worked fine in phone 8.0 but not 8.1 runtime it seems.
<SettingsFlyout
x:Class="popcornpk.Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:popcornpk"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
IconSource="Assets/SmallLogo.png"
Title="CustomSetting" >
<!-- This StackPanel acts as a root panel for vertical layout of the content sections -->
<StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<!-- Toggle switch -->
<StackPanel >
<TextBlock Text="Toggle Switch" Style="{StaticResource TitleTextBlockStyle}"/>
<TextBlock Margin="0,0,0,25" Text="Use toggle switches to let users set Boolean values." Style="{StaticResource BodyTextBlockStyle}"/>
<ToggleSwitch Margin="-6,0,0,0" Header = "Download updates automatically" HorizontalAlignment="Left" HorizontalContentAlignment="Left"/>
<ToggleSwitch Margin="-6,0,0,0" Header = "Install updates automatically" HorizontalAlignment="Stretch"/>
</StackPanel>
<!-- Button -->
<StackPanel >
<TextBlock Text="Push button" Style="{StaticResource TitleTextBlockStyle}"/>
<TextBlock Text="Button label" Style="{StaticResource BodyTextBlockStyle}"/>
<Button Margin="-3,0,0,0" Content="Clear"/>
<TextBlock Margin="0,0,0,25" Text="With a push button, users initiate an immediate action." Style="{StaticResource BodyTextBlockStyle}"/>
</StackPanel>
<!-- ComboBox -->
<StackPanel >
<TextBlock Text="ComboBox" Style="{StaticResource TitleTextBlockStyle}"/>
<TextBlock Margin="0,0,0,25" Text="Use the ComboBox to allow users to select one item from a set of text-only items." Style="{StaticResource BodyTextBlockStyle}"/>
<ComboBox Header="State:" Margin="0,7,0,0" SelectedIndex="0" HorizontalAlignment="Left">
<ComboBoxItem Content="Washington"/>
<ComboBoxItem Content="Oregon"/>
<ComboBoxItem Content="California"/>
</ComboBox>
</StackPanel>
<!-- HyperlinkButton -->
<StackPanel >
<TextBlock Text="Hyperlink" Style="{StaticResource TitleTextBlockStyle}"/>
<TextBlock Margin="0,0,0,25" Text="Use a hyperlink when the associated action will take the user out of this flyout." Style="{StaticResource BodyTextBlockStyle}"/>
<HyperlinkButton Padding="-5,0,0,0" Content="View privacy statement" Tag="http://privacy.microsoft.com" HorizontalAlignment="Left"/>
</StackPanel>
<!-- TextBox -->
<StackPanel >
<TextBlock Text="TextBox" Style="{StaticResource TitleTextBlockStyle}"/>
<TextBlock Margin="0,0,0,25" Text="Use a TextBox to allow users to enter text." Style="{StaticResource BodyTextBlockStyle}"/>
<StackPanel Margin="0,7,0,0" Orientation="Horizontal">
<TextBox HorizontalAlignment="Left" Width="150"/>
<Button Margin="20,0,0,0" Content="Add"/>
</StackPanel>
</StackPanel>
<!-- RadioButton -->
<StackPanel>
<TextBlock Text="Radio button group" Style="{StaticResource TitleTextBlockStyle}"/>
<TextBlock Margin="0,0,0,25" Text="Lets users choose one item from a small set of mutually exclusive, related options." Style="{StaticResource BodyTextBlockStyle}"/>
<TextBlock Text="Video quality" Style="{StaticResource BodyTextBlockStyle}"/>
<RadioButton Margin="0,7,0,0" Content="High"/>
<RadioButton Margin="0,17,0,0" Content="Medium"/>
<RadioButton Margin="0,17,0,0" Content="Low"/>
</StackPanel>
</StackPanel>
Severity Code Description Project File Line
Error CS0263 Partial declarations of 'Settings' must not specify different base classes popcornpk C:\Users\david\Documents\Visual Studio 2015\81StoreLiveAppsPhoneOnlyLIVE\popcornpk\popcornpkhub\popcornpk\popcornpk\obj\Debug\Settings.g.i.cs 15
My base class is just the same as other pages
Note 2
public partial class Settings : Page
I changed above to settings and it compiled but the flyount did not work or popup so it didnt any idea as to why it didnt.
Note 2
To Avoid confusion I dont want a base page of page I wanted to be able to use the settingsflyout that was part of 8.0 apparently microsoft have dicthced this though for 8.1 UAP
The exception tells you everything you need to know.
Look at your xaml. Here's the top two lines of your file:
<SettingsFlyout
x:Class="popcornpk.Settings"
This says that you're declaring a new class called popcornpk.Settings (btw, namespaces should be PascalCased) that extends the base class SettingsFlyout.
When you add a new xaml file to your application, it actually creates three files--the .xaml file, a .xaml.cs file that you edit, and a mysterious ephemeral .g.i.cs file that holds designer-generated code (e.g., the implementation of InitializeComponent()).
The .xaml.cs and .g.i.cs files are partial class files, and are combined by the compiler. Note what the exception message says--
Partial declarations of 'Settings' must not specify different base classes
What are these different base classes?
Well, from the xaml, we can see the first one--SettingsFlyout.
From your snippet,
public partial class Settings : Page
We see the other base class--Page.
Not sure how you screwed that up, but the simple fix is to remove the base class declaration from your .xaml.cs file:
public partial class Settings
{
// snip
Apart from what Will has said about partial classes, which will surely solve the error, you probably won't be able to use SettingsFlyout on Phone - following the remarks:
Caution SettingsFlyout is supported only for use with the SettingsPane in Windows 8. While the SettingsFlyout type is visible in Windows Phone projects, SettingsPane is not present on Windows Phone, so use of SettingsFlyout is not supported.

Add custom button to Form ControlBox

I want to know how to add additional button to Form ControlBox that is present at image below:
I know in this forum are few similar questions but no single one answered my question. I checked few links and its not that what i expected because its not working at every operating system. I checked those links:
http://www.codeproject.com/Articles/11510/Add-Transparent-Menus-and-XP-Titlebar-Buttons-to-y
http://www.codeproject.com/Articles/10171/Adding-a-Minimize-to-tray-button-to-a-Form-s-capti
Other idea is to change default click event and icon for MaximizeBox because i don't need this one in my app.
Scratch this - just realized it's a Winforms issue.
Kinda lame suggestion, but in WPF I'd do:
Drop the title
<Window> ... WindowStyle="None" ... /<Window>
Then roll my own:
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
<Button HorizontalAlignment="Right" Width="25" Content="Yo!"/>
<Button HorizontalAlignment="Right" Width="20" Content="-"/>
<Button HorizontalAlignment="Right" Width="20" Content="■"/>
<Button HorizontalAlignment="Right" Width="20" Content="X"/>
</StackPanel>
Caveats:
You will have to do a mouse capture to move the window, not difficult but not trivial either. Also change the style of the buttons to look like the regular icons etc
Not ideal I know, but in a pinch ...

Silverlight Tooltip Remain Visible With Mouseover

Hello and thanks for the help. I have a Treeview that I am populating with a Hierarchical data template, and currently the bottom nodes have a tooltip that generates a small stack panel that is populated with data specific to the item the mouse hovers over. I also have a button sitting in the tooltip, however, as the tooltip does not persist when the mouse moves over it, I am unable to make use of the button like I need to. My xaml looks like this:
<!--=========================== Hierarchical Data template for tree view -->
<!--template for bottom nodes-->
<sdk:HierarchicalDataTemplate x:Key="ModTemplate" ItemsSource="{Binding ApplicationModules}">
<StackPanel Orientation="Horizontal" > <!--======tooltip style to handle format for callout window============-->
<ToolTipService.ToolTip>
<ToolTip HorizontalOffset="0" VerticalOffset="0" Style="{StaticResource ModuleToolTipStyle}">
<StackPanel Width="150" Height="auto" >
<TextBlock Text="Module Info" FontWeight="Bold" TextAlignment="Center"/>
<TextBlock Text="Module State:" FontWeight="Bold" />
<TextBlock Text="{Binding Path=ModInfo.ModuleState}" />
<TextBlock Text="Module Start Time:" FontWeight="Bold" />
<TextBlock Text="{Binding Path=ModInfo.ModuleStartTime}"/>
<TextBlock Text="Module Down Time:" FontWeight="Bold"/>
<TextBlock Text="{Binding Path=ModInfo.ModuleDownTime}" />
<Button Content="More Info" Width="75"></Button>
</StackPanel>
</ToolTip>
</ToolTipService.ToolTip>
<!--============end tooltip style for callout window===================-->
<ContentPresenter Margin="0 0 4 0" Content="{Binding Icon}" />
<TextBlock FontStyle="Italic" Text="{Binding Path=ModuleName}" />
</StackPanel>
</sdk:HierarchicalDataTemplate>
I would like the tooltip to persist when the mouse moves over it so that I can wire an event to the button. How can I achieve this? Thanks again for the help.
You have a couple options to accomplish your goal that I'm aware of. You can go check out the Silverlight Advanced Tooltips project over on codeplex which does what you want (though I personally have not used it so can't give any kind of review.)
Or you can make your own with some creativity. If it were me I would probably skip all that mess, forget the ToolTipService all together and just make my own to dress it up since to a user, what you're providing isn't what they're used to in terms of a tooltip expectation anyway and have cross more over to a callout or popout functionality. I can make an example as soon as I get some freed up time if option #1 doesn't work for you but I hope it does. Essentially both my way, and that project link I provided would do the same thing, which is provide a delay after the MouseLeave event of what it's attached to so the user can get to it before it disappears. Then hand off its visibility condition to that object. Let me know if this doesnt work and I can give you an alternative example using nothing but XAML.

Categories