var messageBoxResult = MessageBox.Show(AppResources.TextDeleteConfrimation,
AppResources.TextDelete, MessageBoxButton.OKCancel);
if (messageBoxResult == MessageBoxResult.OK)
{
DeleteSomething();
}
2012年11月22日 星期四
MessageBox for confirmation
Code snipplet:
2012年11月11日 星期日
How to load a string from Resource.resw, and add a item to settings panel on Windows 8
The keyword is SettingsPane.
In OnLaunched() in App.xaml.cs:
Then implement CommandsRequested() itself.
In OnLaunched() in App.xaml.cs:
SettingsPane.GetForCurrentView().CommandsRequested += CommandsRequested;
Then implement CommandsRequested() itself.
private void CommandsRequested(SettingsPane aSender, SettingsPaneCommandsRequestedEventArgs aEventArgs)
{
// Retrieve all the strings first
var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
string settingsCommandId = loader.GetString("aText");
string label = loader.GetString("aText");
//add the commands to the setting panel
aEventArgs.Request.ApplicationCommands.Add(
new SettingsCommand(settingsCommandId, label, aMethod));
}
2012年10月31日 星期三
2012年9月20日 星期四
windows 8 set focus
It seems that there is no setFocus() method anymore. Instead, windows 8 includes the Windows.UI.Xaml.FocusState for different focus state, like: pointer, keyboard, etc.
The usage would be like:
ViewObjectName.Focus(Windows.UI.Xaml.FocusState.Pointer);
The usage would be like:
ViewObjectName.Focus(Windows.UI.Xaml.FocusState.Pointer);
2012年9月10日 星期一
Run a program as administrator
http://www.intowindows.com/run-program-as-administrator-in-windows-8/
1. press windows to go to start screen
2. open search screen to search the program that you want to run. (i.e. cmd.exe)
3. the search result will be shown on the left hand side.
4. right click on it (tile of cmd.exe)
5. click on advanced
6. check run as adminstrator
1. press windows to go to start screen
2. open search screen to search the program that you want to run. (i.e. cmd.exe)
3. the search result will be shown on the left hand side.
4. right click on it (tile of cmd.exe)
5. click on advanced
6. check run as adminstrator
2012年9月3日 星期一
Launch Browser with an URI from a win8 app
http://zubairahmed.net/?p=266
Here is the code snippet:
Here is the code snippet:
Uri justUri = new Uri("http://www.google.com");
await Windows.System.Launcher.LaunchUriAsync(justUri);
2012年8月12日 星期日
metro style -- switch to a new page
In metro style, when switching from a page to another page.
If the new page is a blank page when you add it into your project.
We usually do like this:
On the opening page, we need to implement onNavigateTo() method to do the corresponding jobs. Most cases, it is crucial to use the parameter that is passing in, i.e. itemId. here is an example of how to do it.
or if it is a detail page when adding it,
put the code in LoadState(){}
If the new page is a blank page when you add it into your project.
We usually do like this:
this.Frame.Navigate(typeof(NewsPage), itemId);
On the opening page, we need to implement onNavigateTo() method to do the corresponding jobs. Most cases, it is crucial to use the parameter that is passing in, i.e. itemId. here is an example of how to do it.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Story article = e.Parameter as Story;
BitmapImage bmpimg= getCoverImage(article);
if (null == bmpimg)
{
// todo: show empty image...
}
else
{
picture.Source = getCoverImage(article);
}
}
or if it is a detail page when adding it,
put the code in LoadState(){}
2012年8月9日 星期四
How To unit test in metro style apps?
http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-529T?format=progressive
One hell good video!
key:
1. bind xaml controls to data objects.
2. implement ICommand interface
3. care the manifest file.
One hell good video!
key:
1. bind xaml controls to data objects.
2. implement ICommand interface
3. care the manifest file.
訂閱:
文章 (Atom)