Windows Phone – Progress popup and AutoCompleteBox

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

2 thoughts on “Windows Phone – Progress popup and AutoCompleteBox”

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

Leave a Reply

Your email address will not be published. Required fields are marked *