- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
<primitives:Popup x:Name="MyPopup"> content </primitives:Popup> in Visual Basic .NET
<primitives:Popup x:Name="MyPopup"> content </primitives:Popup> QR Code Encoder In VB.NET Using Barcode creation for VS .NET Control to generate, create QR Code ISO/IEC18004 image in .NET applications. www.OnBarcode.comRecognize Denso QR Bar Code In Visual Basic .NET Using Barcode decoder for .NET framework Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comTo display the pop-up in the example, you d then use the IsOpen property: Making Code 128A In Visual Basic .NET Using Barcode encoder for VS .NET Control to generate, create Code128 image in .NET applications. www.OnBarcode.comMake Universal Product Code Version A In Visual Basic .NET Using Barcode maker for .NET Control to generate, create UPCA image in VS .NET applications. www.OnBarcode.comMyPopup.IsOpen = true; Print GS1-128 In Visual Basic .NET Using Barcode maker for .NET Control to generate, create UCC - 12 image in .NET framework applications. www.OnBarcode.comPDF-417 2d Barcode Maker In Visual Basic .NET Using Barcode encoder for VS .NET Control to generate, create PDF 417 image in Visual Studio .NET applications. www.OnBarcode.comIn Silverlight 3 and 4, the use of the Popup control is more for floating nondialog items to the top of the stack, but not really for simulating dialog boxes, so we won t spend much time on it. The Popup control is used by Silverlight to support other elements such as tooltips, the drop-down in the ComboBox, and, of course, the ChildWindow control introduced with Silverlight 3. GS1 - 13 Creation In Visual Basic .NET Using Barcode creator for VS .NET Control to generate, create EAN 13 image in Visual Studio .NET applications. www.OnBarcode.comCreating Uniform Symbology Specification Code 93 In VB.NET Using Barcode creation for VS .NET Control to generate, create Code 9/3 image in .NET applications. www.OnBarcode.com15.5.2 Displaying a dialog box with the ChildWindow control Silverlight 3 introduced a new class, ChildWindow, which provides a window-like experience over the base Popup control. Where the Popup control provided only z-order management, the ChildWindow adds window overlays, dialog results, OK/Cancel buttons, and window title functionality. QR Code ISO/IEC18004 Creation In None Using Barcode drawer for Font Control to generate, create QR Code image in Font applications. www.OnBarcode.comDecode QR In Visual Studio .NET Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comDownload from Wow! eBook <www.wowebook.com>
1D Creation In VS .NET Using Barcode creation for ASP.NET Control to generate, create Linear 1D Barcode image in ASP.NET applications. www.OnBarcode.comCode 128B Creation In None Using Barcode generator for Microsoft Excel Control to generate, create ANSI/AIM Code 128 image in Office Excel applications. www.OnBarcode.comShowing dialogs and pop-ups
Print EAN / UCC - 14 In None Using Barcode encoder for Online Control to generate, create UCC-128 image in Online applications. www.OnBarcode.comBarcode Generator In .NET Framework Using Barcode generation for Reporting Service Control to generate, create Barcode image in Reporting Service applications. www.OnBarcode.comThe Silverlight ChildWindow is a first-class element like UserControl and Page.
Reading ECC200 In C# Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comCreating Barcode In Java Using Barcode generation for Java Control to generate, create Barcode image in Java applications. www.OnBarcode.comUnlike Popup, ChildWindow is considered a first-class element, like Page and UserControl, and has a template in the project items template list, as shown in figure 15.11. That said, ChildWindow isn t located in the core Silverlight runtime; it s located in the System.Windows.Controls assembly in the SDK. The primary reason for keeping it out of the runtime is that it s not an essential or enabling technology; you could live with Popup if you absolutely needed to. After you create a new ChildWindow, you re presented with its default template, as shown in listing 15.5. GS1 - 12 Generator In None Using Barcode maker for Microsoft Excel Control to generate, create UPC Code image in Office Excel applications. www.OnBarcode.comBarcode Creator In Java Using Barcode printer for Eclipse BIRT Control to generate, create Barcode image in Eclipse BIRT applications. www.OnBarcode.comListing 15.5 The default ChildWindow template
QR Code Creation In None Using Barcode generator for Font Control to generate, create QR Code image in Font applications. www.OnBarcode.comCode 3 Of 9 Decoder In None Using Barcode reader for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comResult: XAML: <controls:ChildWindow x:Class="SilverlightApplication20.ChildWindow1" 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; Download from Wow! eBook <www.wowebook.com>
Navigation and dialogs
assembly=System.Windows.Controls" Width="400" Height="300" Title="ChildWindow1"> <Grid x:Name="LayoutRoot" Margin="2"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> Window content goes
<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> Listing 15.5 shows the default look and feel of the ChildWindow control. Before we get into how to customize that, we ll cover the mechanics of showing and hiding the window. SHOWING THE CHILDWINDOW
A ChildWindow is typically displayed from code rather than included as an inline element in XAML. To facilitate this, the control has several members that handle showing, closing, reporting results, and allowing cancellation. Table 15.8 lists those members and their related functions. Table 15.8 Properties, methods, and events related to showing and closing the ChildWindow Description A nullable boolean that indicates whether the dialog was accepted or cancelled. This is typically set to true in the handler for an OK button and false in the handler for a Cancel button. Displays the child window and immediately returns. Whereas the behavior of a ChildWindow is logically modal, from a programmatic standpoint, Show is a nonblocking and therefore nonmodal method. Closes the window. Typically, this is called from a button on the child window itself. Raised when the child window is closing. The handler for this event has the opportunity to cancel the close operation and force the window to stay open. Raised after the child window has been closed. Note that due to animations, the window may still be visible on the screen for a moment longer, but it s be in the process of closing for good. Use this event to inspect the DialogResult property. Member
DialogResult
property
Show method
Close method Closing event Closed event
Download from Wow! eBook <www.wowebook.com>
Showing dialogs and pop-ups
The typical way to use a ChildWindow is to call the Open method from code and then to take some action based on the dialog result available during the Closed event. Listing 15.6 shows this process in more detail. Listing 15.6 Displaying a ChildWindow and capturing the DialogResult
void MainPage_Loaded(object sender, RoutedEventArgs e) { ChildWindow dialog = new MyDialog(); dialog.Closed += (s, ea) => { if (dialog.DialogResult == true) { ... } else if (dialog.DialogResult == false) { ... } else { ... } }; dialog.Show(); } User clicked OK User clicked Cancel
The example shows how to display a ChildWindow and handle the three possible DialogResult values set when the user closes the window. Note that this example also uses a lambda expression to create the event handler. This is a shortcut way to create a delegate inline in your code rather than create a separate event handler function. In this example, s is the variable that contains the sender, and ea is the variable that contains the event arguments. The code to display the window could also have been written like this: ChildWindow dialog = new MyDialog(); dialog.Closed += new EventHandler(dialog_Closed); dialog.Show(); Of course, in that instance, you d need to create a separate function named dialog_Closed that had the event handler logic in it. Either way is valid. Note also that you do a true/false/else check on the DialogResult value. This is because the DialogResult is a nullable boolean type, and it s not usually sufficient to check for true or false. Nullable booleans also don t allow you to write code like this: if (dialog.DialogResult) { ... } You ll get a compile-time error unless you cast the value to a regular bool. For that reason, you check explicitly against true, false, and the null (default) value. When you ran the code in listing 15.6, you probably noticed that the content behind the window was overlaid with a gray rectangle. The color and opacity of the overlay are a couple of the knobs you can tweak to customize the way the ChildWindow looks.
|
|