Discussing the nuts and bolts of software development

Monday, May 11, 2009

 

XBAP - Using the Popup Control as a Dialog Box

How many people have experienced the modal pop up in desktop applications? They are commonly used across a wide variety of applications, one could say, too commonly used. While not appropriate for all situations, sometimes you need to use a pop up.

In XBAP applications the ability to open a pop-up is very limited; in many cases you will use navigation and multiple pages instead of separate windows. In most cases this is sufficient, but sometimes you really need to use a pop-up, and when you do a simple work around is to use the Popup control offered by WPF.

First, you define the Popup in the markup, making sure to set its StaysOpen property to true so it will remain open until you close it. (There’s no point in using the PopupAnimation or AllowsTransparency properties, because they won’t have any effect in a web page.) Include suitable buttons, such as OK and Cancel, and set the Placement property to Center so the popup will appear in the middle of the browser window.

Code sample:

<Popup Name="dialogPopUp" StaysOpen="True" Placement="Center" MaxWidth="200">
    <Border>
        <Border.Background>
            <LinearGradientBrush>
                <GradientStop Color="AliceBlue" Offset="1"></GradientStop>
                <GradientStop Color="LightBlue" Offset="0"></GradientStop>
            </LinearGradientBrush>
        </Border.Background>
        <StackPanel Margin="5" Background="White">
            <TextBlock Margin="10" TextWrapping="Wrap">Please enter your name.
            </TextBlock>
            <TextBox Name="txtName" Margin="10"></TextBox>
            <StackPanel Orientation="Horizontal" Margin="10">
                <Button Click="dialog_boxOK_Click" Padding="3" Margin="0,0,5,0">OK</Button>
                <Button Click="dialog_boxCancel_Click" Padding="3">Cancel</Button>
            </StackPanel>
        </StackPanel>
    </Border>
</Popup>

At the appropriate time (for example, when a button is clicked), disable the rest of your user interface and show the Popup. To disable your user interface, you can set the IsEnabled property of some top-level container, such as a StackPanel or a Grid, to false. (You can also set the Background property of the page to gray, which will draw the user’s attention to Popup.) To show the Popup, simply set its IsVisible property to true.

Here’s an event handler that shows the previously defined Popup:


private void popupTriggerButton_Click(object sender, RoutedEventArgs e)
{
    DisableMainPage();
}
 
private void DisableMainPage()
{
    mainPage.IsEnabled = false;
    this.Background = Brushes.LightGray;
    dialogPopUp.IsOpen = true;
}

When the user clicks the OK or Cancel button, close the Popup by setting its IsVisible property to false, and re-enable the rest of the user interface:


private void dialog_boxOK_Click(object sender, RoutedEventArgs e)
{
    // Copy name from the Popup into the main page.
    lblName.Content = "You entered: " + txtName.Text;
    EnableMainPage();
} 
 
private void dialog_boxCancel_Click(object sender, RoutedEventArgs e)
{
    EnableMainPage();
}
 
private void EnableMainPage()
{
    mainPage.IsEnabled = true;
    this.Background = null;
    dialogPopUp.IsOpen = false;
}

Using the Popup control to create this workaround has one significant limitation. To ensure that the Popup control can’t be used to spoof legitimate system dialog boxes, the Popup window is constrained to the size of the browser window. If you have a large Popup window and a small browser window, this could chop off some of your content. One solution is to wrap the full content of the Popup control in a ScrollViewer with the VerticalScrollBarVisibility property set to Auto.

If a Popup isn’t suitable for you, you can try another more “interesting” approach for showing a dialog box. Using the Windows Form library from .NET 2.0 you can safely create and host any WinForm control in your WPF application. In this case, you can create and show an instance of the System.Windows.Forms.Form class (or any custom form that derives from Form), because it doesn’t require unmanaged code permission. In fact, you can even show the form modelessly, so the page remains responsive. The only drawback is that a security balloon automatically appears superimposed over the form and remains until the user clicks the warning message. You’re also limited in what you can show in the form. Windows Forms controls are acceptable, but WPF content isn’t allowed.

Labels: , , , , ,


Comments:
merci Romeo ests exact ce cautam
 
In xbap,I hope property placement will not work.We should use placementTarget.


But by using placementTarget,can we set the position to center or mousepoint????Please help me out
 
If you want to write your scholarship essay, I recommend you to read https://justbuyessay.com/blog/scholarship-essay. Here you can read quite useful writing tips.
 
Systematic stop the dialogs process. For example, to stop the application of the process of closing you’re weighing silver page with Wiki Page Creators can be useful if you want a man first, for example you have to not close the application.
 
We provide AllAssignmentHelp to students of any college in their United States. Our all students are also given 2-4 * 7 support and service. Best Biology Dissertation Help Online
 


Thanks for share this POST
ارخص شركات نقل اثاث بالرياض





 
Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, we can see more on this. Are you aware of any other websites on this subject.
Essay Writing Service

 
Amazing Article, Really useful information to all So, I hope you will share more information to be check and share here.


Pygame Tutorial
Pygame Download
Pygame Install
Matplotlib Python
Matplotlib Tutorial
Matplotlib install
PouchDB Tutorial
What is PouchDB
PouchDB Installation
pouchdb server
 
Using the Popup control to create this workaround has one significant limitation. To ensure that the Popup control can’t be used to spoof legitimate system dialog boxes, the Popup window is constrained to the size of the browser window. buy online pakistani lawn , gul ahmed lawn 2016 with price online shopping , gul ahmed lawn sale 2015 with price , pakistani lawn suits price 2015 , alkaram lawn silk dupatta , 2 piece lawn suits If you have a large Popup window and a small browser window, this could chop off some of your content. One solution is to wrap the full content of the Popup control in a ScrollViewer with the VerticalScrollBarVisibility property set to Auto.
 
Thanks for sharing this.,
Leanpitch provides online training in CSPO during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSPO Certification Workshop in different cities.

CSPO certification

Product owner certification
 
Thanks for sharing this.,
Leanpitch provides online training in CSPO during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSPO Certification Workshop in different cities.
CSPO certification online

Certified scrum product owner
 
Thanks for sharing this.,
Leanpitch provides online training in CSPO during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSPO Certification Workshop in different cities.
CSPO online certification

CSPO certification cost
 
Thanks for sharing this.,
Leanpitch provides online training in CSPO during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSPO Certification Workshop in different cities.
CSPO TRAINING ONLINE

CSPO ONLINE TRAINING
 
Thanks for sharing this.,
Leanpitch provides online training in CSPO during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSPO Certification Workshop in different cities.
CSPO TRAINING

CSPO ONLINE
 
Wikipedia consulting is a great way for a company to increase traffic and sales online. KeywordsFly is a Wikipedia consulting firm that can publish articles written in a way that will rank on the front page of Google.

 
All this is because he has not yet entered this site https://www.masterpapers.com/essay-writer, where they will perform absolutely all types of written work, and most importantly, without errors, write everything beautifully, thanks to the assistant
 
very nice post, Tips of the translation have been floated for the help of the students.
 
To write my essay cheap write to the support service. The essay support service takes full responsibility for completing the assignment, and you just enjoy your free evening. Stop being a spectator from time to time in your own life. One more essay can be crafted for you, but your social life and health cannot. The final work will have one line spacing, which automatically doubles the number of words on page 1 page - 550 words, 2 page - 1100 words, etc.
 
In some cases, understudies feel focused on the grounds that they are uncertain with regard to their composing tasks. All things considered, making a decent attempt doesn't constantly mean coming by the most ideal outcome, and Buy Essay Paper Online educators evaluate all works as per various severe prerequisites. Research papers are particularly interesting since you really want to audit and refer to different sources while likewise making your own statement.
 
Creating solid contentions, at the same time keeping away from counterfeiting, and following the required organization can now and again demonstrate close to make my assignment for me incomprehensible. Fortunately, you don't need to confront scholastic difficulties alone. There's a choice to pay for research papers and get quality assistance from proficient experts who've gone through numerous years helping battling students.
 
Amazing post! Went a weekend on PS4 and not ready for an essay? ... will help you write an essay for you. The key aspect of this task is finding a reliable college writing paper service.
 
Guangzhou Umeier Ecotech Co., Limited (Umeier) is the quickest developing shrewd aroma diffuser producer in China. A portion of our understanding items incorporate fragrance electric diffuser and rejuvenating oil diffuser.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?