AboutPrompt

Overview

Basically AboutPrompt is an UI component that derives from the toolkit`s abstract PopUp<T, TPopUpResult> class . As its name says it is a kind of extended popup which prompt for the OK button click .This control can display different content like Title, VersionName, WaterMark etc .


Getting Started

To begin using AboutPrompt first add a reference to the Coding4Fun.Phone.Controls.dll assembly.

Creating AboutPrompt:

C#:
AboutPrompt about = new AboutPrompt();
about.Completed += about_Completed;
about.Show();

void about_Completed(object sender, PopUpEventArgs<object, PopUpResult> e)
{
     //add some code here
}

Key Features

AboutPrompt exposes the following properties that can be used to customize its content:
  • WaterMark,
  • VersionNumber
  • Title
  • Body
  • Footer
  • HasGesturesDisabled

NOTE: What is the HasGesturesDisabled property? : With the current Gesture Service in the Silverlight Toolkit (November 2010 release), if two controls are overlapped and the bottom control has a listener attached, events will still bubble through with no way to cancel it without putting on a listener. In a control that is called PopUp, it is self defeating to have this bubble through effect happening. If the SL toolkit corrects the behavior, we’ll remove the HasGesturesDisabled property as it would no longer be needed. This would also remove the dependency on the Silverlight Toolkit.

When you want to show the AboutPrompt you can choose between 3 overloads of the Show() method:
  • Show()
  • Show(string authorName, string twitterName = null, string emailAddress = null, string websiteUrl = null)
  • Show(params AboutPersonItem[] people) - This method accepts an array of AboutPersonItem items.

AboutPersonItem is a simple control that represents information about a single person and exposes the following properties of type string:
  • WebSiteUrl
  • Role
  • EmailAddress
  • AuthorName

When the AboutPrompt popup is closed the Completed event is fired.

Example1:
AboutPrompt about = new AboutPrompt();
about.Title = "Coding4fun";
about.Footer = @"http://coding4fun.codeplex.com/";
about.VersionNumber = "Version 1.5";
about.WaterMark = "AboutPropmt WaterMark string";
about.Body = new TextBlock { Text = "This is a demo of the Coding4fun AboutPrompt Body!", TextWrapping = TextWrapping.Wrap};
about.Completed += about_Completed;
about.Show();



Example2:
AboutPrompt p = new AboutPrompt();
p.Title = "AboutPersonItem test";
AboutPersonItem item = new AboutPersonItem();
item.AuthorName = "WindowsPhoneGeek";
item.EmailAddress = @"support@windowsphonegeek.com";
item.Role = "n/a";
item.WebSiteUrl = @"www.windowsphonegeek.com";
 
p.Show(item);



Example3:
AboutPrompt p = new AboutPrompt();
p.Show("Coding4fun", "@Coding4fun", "support@coding4fun.com", @"http://coding4fun.codeplex.com");



Example4:
Generally the AboutPrompt is designed to be used in code but sometimes users want to put some composite elements into the popup body so in this case it is easy to define these element is XAML. Here is one possible solution with UserControl. Just create a new UserControl named for example AboutPromptBody and add the following code into it:

AboutPromptBody UserControl:
<Border BorderBrush="YellowGreen" BorderThickness="2">
    <StackPanel x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
    <TextBlock Text="Body declared in UserControl XAML"/>
    <Image Source="images/logo.png" Height="80" Width="80" HorizontalAlignment="Left"/>
    <TextBlock Text="This is the first text in the Body section."/>
    <Border Background="YellowGreen" Height="100" Width="400">
        <TextBlock Text="Another Body content here" VerticalAlignment="Center"/>
    </Border>
    </StackPanel>
</Border>

MainPage.xaml.cs
AboutPrompt p = new AboutPrompt();
p.Title = "UserControl test";
p.Body = new AboutPromptBody();
p.Show();


Last edited Feb 9, 2011 at 8:32 PM by WinPhoneGeek, version 6

Comments

wenbbaa Apr 10, 2013 at 4:40 AM 
hi!
I want to ask, how to set Background?
Is it invalid?

toninocatapano Oct 21, 2012 at 1:33 PM 
Hello, my name is Tony
and my problem with AboutPrompt is very strange:
I got this Exception:
NullPointerException at Coding4Fun.Phone.Controls.PopUp`2.b__3() at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Delegate.DynamicInvokeOne(Object[] args) at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) at System.Delegate.DynamicInvoke(Object[] args) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority) at System.Windows.Threading.Dispatcher.OnInvoke(Object context) at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args) at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args) at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
but it happen only 1/10 times.
I initilize and show my AboutPrompt in the Constructor (i've also tried to move to OnNavigatedTo method but still got the issue):
namespace My_App {
public partial class MyClass: PhoneApplicationPage {
public MyClass() {
InitializeComponent();
AboutPrompt about = new AboutPrompt();
about.show();
}
}
}
I've got the same problem if I substitute AboutPrompt with MessagePrompt.
How can i solve this problem? I'm getting mad.
Thank you very much in advance.
Tony

mkrain Dec 6, 2011 at 9:42 PM 
I'm using the MVVM lite RelayCommad in order to move most business logic to my view models. Is there a way I can show these dialog boxes without using .Show() in the view? Does setting Visibility also trigger the dialog boxes? Currently I'm using a visibility property on a view model bound to visibility on a border control.

AlonR May 15, 2011 at 5:10 AM 
Hi, what is the size of the user control?