Showing posts with label Windows Store App. Show all posts
Showing posts with label Windows Store App. Show all posts

Monday, April 1, 2013

MessageDialog - Windows Store App MessageBox.Show Equivalent.

If you are new to Windows Store app development, you may be wondering how to show a simple dialog. It used to be so easy. You simply called MessageBox.Show() and you had a dialog. Well, in Windows Store Applications in Windows 8, it is a bit different but just as easy.

Try this code instead of MessageBox.Show to get the following dialog…

var messageDialog = new Windows.UI.Popups.MessageDialog("Message Text.","Message Header");
messageDialog.ShowAsync();


image


Happy Windows Store App Coding!



Sunday, March 31, 2013

Windows Store App… How to set focus on a textbox

A common task in UI development is setting the focus on a textbox when navigating to a particular screen. When doing this on a Windows 8 application, a lot of developers try to do this inside the OnNavigatedTo event handler. This does not work. To set the focus on a textbox when the page is hit, call the focus method on the particular textbox inside the loaded event handler… That should do it.

<common:LayoutAwarePage
x:Name="pageRoot"

Loaded="pageRoot_Loaded_1">



private void pageRoot_Loaded_1(object sender, RoutedEventArgs e)
{
this.txtName.Focus(FocusState.Programmatic);
}



Hope this helps. Happy Coding!