Skip to content

Instantly share code, notes, and snippets.

@jimoneil
Created May 13, 2013 16:01
Show Gist options
  • Save jimoneil/5569410 to your computer and use it in GitHub Desktop.
Save jimoneil/5569410 to your computer and use it in GitHub Desktop.
code sample for hooking up Callisto controls to Settings flyout in a Windows Store app
// LICENSE: http://opensource.org/licenses/ms-pl
//
// This gist contains code that references the open source Callisto toolkit (http://callistotoolkit.com/)
// implementation of OnNavigated to for a given page in a Windows Store App
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// handle Settings pane options
SettingsPane settingsPane = Windows.UI.ApplicationSettings.SettingsPane.GetForCurrentView();
settingsPane.CommandsRequested += (s, e2) =>
{
e2.Request.ApplicationCommands.Add(
new SettingsCommand("About", "About",
(x) => ShowSettingsFlyout("About", new AboutFlyout()))
);
e2.Request.ApplicationCommands.Add(
new SettingsCommand("Support", "Support",
(x) => ShowSettingsFlyout("Support", new SupportFlyout()))
);
e2.Request.ApplicationCommands.Add(
new SettingsCommand("Privacy", "Privacy Statement",
(x) => ShowSettingsFlyout("Privacy Statement", new PrivacyFlyout()))
);
};
}
/// <summary>
/// Show a settings flyout using the Callisto toolkit (http://callistotoolkit.com/)
/// </summary>
/// <param name="title">Name of flyout</param>
/// <param name="content">UserControl containing the content to be displayed in the flyout</param>
/// <param name="width">Flyout width (narrow or wide)</param>
private async void ShowSettingsFlyout(string title, Windows.UI.Xaml.Controls.UserControl content,
SettingsFlyout.SettingsFlyoutWidth width = SettingsFlyout.SettingsFlyoutWidth.Narrow)
{
// grab app theme color from resources (optional)
SolidColorBrush color = null;
if (App.Current.Resources.Keys.Contains("AppThemeColor"))
color = App.Current.Resources["AppThemeColor"] as SolidColorBrush;
// create the flyout
var flyout = new SettingsFlyout();
if (color != null) flyout.HeaderBrush = color;
flyout.HeaderText = title;
flyout.FlyoutWidth = width;
// access the small logo from the manifest
flyout.SmallLogoImageSource = new BitmapImage((await AppManifestHelper.GetManifestVisualElementsAsync()).SmallLogoUri);
// assign content and show
flyout.Content = content;
flyout.IsOpen = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment