Well there are two ways i can think of showing modal popup. One way would the be the popular one by Silverlight Tutorial Part 6: Using User Controls to Implement Master/Detail Scenario Another way would be to use the more recent control released on Silverlight 3.0. It is very easy to implement. In this post i will basically show how to implement popup image using ChildWindow control. Add a childwindow to your project and name it ImagePopup.
MyChildWindow.xaml
<controls:ChildWindow x:Class=”Tips.MyChildWindow”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation“
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml“
xmlns:controls=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls”
Width=”400″ Height=”300″
Title=”MyChildWindow”>
<Grid x:Name=”LayoutRoot” Margin=”2″>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height=”Auto” />
</Grid.RowDefinitions>
<Image x:Name=”img” />
<Button x:Name=”CancelButton” Content=”Cancel” Click=”CancelButton_Click” Width=”75″ Height=”23″ HorizontalAlignment=”Right” Margin=”0,12,0,0″ Grid.Row=”1″ />
<Button x:Name=”OKButton” Content=”OK” Click=”OKButton_Click” Width=”75″ Height=”23″ HorizontalAlignment=”Right” Margin=”0,12,79,0″ Grid.Row=”1″ />
</Grid>
</controls:ChildWindow>
MainPage.xaml.cs
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System;
namespace Tips
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
// where images is at the root folder…
MyChildWindow popup = new MyChildWindow();
popup.img.Source = new BitmapImage(new Uri(“images/vaio_Girl.jpg”, UriKind.Relative));
popup.Title = “Image Popup”;
popup.Show();
}
}
}
Output
Sharker Khaleed Mahmud
Software Developer
(MCP,MCTS,MCPD[web])
ScottGu’s Blog
The





