Announcement

All important changes of my site and my blog will be announced here.

Computer security

This is my hobby. I spend my freetime for it. I am not professional in this area. But I like it very much.

Everything Else

Which doesn’t belong to other categories will land here. It maybe about my daily life, entertainment, music, game … or something like that

Programming

This is my job. That means everyday I must sit before the monitor. Tip something, be annoyed by bugs,… but I simply like it.

Tutorial

When I found something interesting, I would like to share it to everyone. That is the reason for this category comes.

Home » Programming

Windows Phone – Progress popup and AutoCompleteBox

Submitted by on Tuesday, 30 March 20102 Comments | 1,718 views

Progress popup
During my development I would like to have a progress popup which shows a dialog telling the user that the program are on working process. The implementation below does not contain a progress bar if you want to can insert a progress bar and update it.

<Popup x:Name="ProgressPopup"
			Width="300"
			IsOpen="False" HorizontalAlignment="Center" VerticalAlignment="Top" d:LayoutOverrides="Width, HorizontalMargin" Margin="89,203,91,0">
	<Border BorderThickness="10"
				BorderBrush="Black"
				Background="DarkGray"
				Padding="30,30">
		<StackPanel>
			<TextBlock Foreground="White"
						FontWeight="Bold"
						FontSize="36"
						x:Name="txt"
						Text="Processing...">
						<TextBlock.Triggers>
							<EventTrigger RoutedEvent="TextBlock.Loaded">
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimation
											AutoReverse="True"
											Duration="0:0:1"
											From="1.0"
											RepeatBehavior="Forever"
											Storyboard.TargetName="txt"
											Storyboard.TargetProperty="Opacity"
											To="0.0"/>
									</Storyboard>
								</BeginStoryboard>
							</EventTrigger>
						</TextBlock.Triggers>
			</TextBlock>
		</StackPanel>
	</Border>
</Popup>

I also add an animation to make the opacity to 0.0 so that I can have a blinking text block. To call this popup, you can use following code to turn on and turn off popup.

this.Dispatcher.BeginInvoke(new Action(() => ProgressPopup.IsOpen = true));
this.Dispatcher.BeginInvoke(new Action(() => ProgressPopup.IsOpen = false));

AutoCompleteBox
The second component I would like to discuss in this post is AutoCompleteBox. If you are developers on Silverlight, you may know there is already a AutoCompleteBox control. However this control is not available on Windows Phone. So if you would like to use this control in Windows Phone, you can simply add reference to the library of this control. After installing Silverlight SDK, the library of AutoCompleteBox should be at “C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.Windows.Controls.Input.dll” (your installation path may vary from mine). Let’s add reference to add and add one instance in page

<phoneNavigation:PhoneApplicationPage
    ...
    xmlns:swci="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
    ...
    Loaded="PhoneApplicationPage_Loaded"
    >
...
<Grid x:Name="ContentGrid" Grid.Row="1">
	<swci:AutoCompleteBox x:Name="acbName" Margin="0,6,0,564"></swci:AutoCompleteBox>
</Grid>

Add database for AutoCompleteBox

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
	List<string> lstNames = new List<string>();
	lstNames.Add("Lewis");
	lstNames.Add("Whitcomb");
	lstNames.Add("Kadi");
	lstNames.Add("Woods");
	lstNames.Add("Shissler");
	lstNames.Add("Fleischer");
	lstNames.Add("Johnson");
	lstNames.Add("Schloen");
	lstNames.Add("Ritner");
	lstNames.Add("Pardee");
	acbName.ItemsSource = lstNames;
}

The AutoCompleteBox will work perfectly in Windows Phone

Popularity: 3% [?]

My strongly recommended books to read. Choose one and enjoy yourself.

Related Posts:

  • No Related Posts

2 Comments »

  • Pham Tien Sinh said:

    I don’t think the AutoCompleteBox works perfectly.
    The style doesn’t fit and it looks very weird when orientation changed

  • Karl Shifflett said:

    Very nice post.

    FYI: A Windows Phone 7 Toolkit was just released witht he AutoCompleteTextBox

    http://silverlight.codeplex.com/releases/view/55034

    Cheers,

    Karl

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.