/// <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 ShowFlyout(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("AppThemeBrush")) { color = App.Current.Resources["AppThemeBrush"] 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; }
private void Button_Click(object sender, RoutedEventArgs e) { if (_lastButton != null) { _lastButton.IsChecked = false; _lastButton = null; } if(_lastPanel!= null) { _lastPanel.Visibility = Visibility.Collapsed; _lastPanel = null; } _lastButton = sender as ToggleButton; var tag = _lastButton.Tag as string; switch (tag) { case "Search": _lastPanel = _searchPanel; break; case "Bibles": _lastPanel = _bibleListPanel; break; case "BibleBooks": _lastPanel = _bibleBookListPanel; break; default: throw new Exception("Button [" + tag + "] not yet supported"); } _lastPanel.Visibility = Visibility.Visible; }
public void ShowFlyout(UserControl control, int width, bool isLightDismiss) { if (popup == null) { popup = new Popup(); popup.Closed += popup_Closed; popup.ChildTransitions = new TransitionCollection(); popup.ChildTransitions.Add(new PaneThemeTransition() { Edge = (SettingsPane.Edge == SettingsEdgeLocation.Right) ? EdgeTransitionLocation.Right : EdgeTransitionLocation.Left }); } Window.Current.Activated += Current_Activated; popup.Width = width; popup.Height = Window.Current.Bounds.Height; popup.IsLightDismissEnabled = isLightDismiss; control.Width = width; control.Height = Window.Current.Bounds.Height; popup.Child = control; popup.SetValue(Canvas.LeftProperty, SettingsPane.Edge == SettingsEdgeLocation.Right ? (Window.Current.Bounds.Width - width) : 0); popup.SetValue(Canvas.TopProperty, 0); popup.IsOpen = true; }
private bool CallOnNavigatedFrom(UserControl page, UserControl newPage) { var method = page.GetType().GetTypeInfo().GetDeclaredMethod("OnNavigatedFrom"); if (method != null) { if (method.GetParameters().Count() == 1) { var finishedAction = new Action(() => { Window.Current.Dispatcher.Invoke( Windows.UI.Core.CoreDispatcherPriority.Normal, delegate { SetPage(newPage); CallOnNavigatedTo(newPage); }, page, null); }); method.Invoke(page, new object[] { finishedAction }); return true; } } SetPage(newPage); CallOnNavigatedTo(newPage); return false; }
/// <summary> /// 利用XAML生成图片,先设置XAML生成图片的用户控件的信息 /// </summary> /// <param name="tileTypeAndName">包含Grid的名称和磁贴类型的键值对</param> /// <param name="tileControl">用户控件</param> public void Configure(KeyValuePair<string, TileTemplateType> tileTypeAndName, UserControl tileControl) { if (gridNameDict == null) { gridNameDict = new Dictionary<KeyValuePair<string, TileTemplateType>, Grid>(); } gridNameDict.Add(tileTypeAndName, tileControl.FindName(tileTypeAndName.Key) as Grid); }
public MainPage() { this.InitializeComponent(); this.Loaded += MainPage_Loaded; TargetUserControl = targetUserControl; HiddenFrame = new Frame(); }
public void show(UserControl control, Point location) { _popUp.Child = control; _popUp.HorizontalOffset = location.X; _popUp.VerticalOffset = location.Y; _popUp.Width = control.Width; _popUp.Height = control.Height; _popUp.IsOpen = true; }
public MySettingsFlyout(UserControl control) : this() { // set the user control... this.UserControl = control; this.StackPanel.Children.Add(control); // subscribe... this.Loaded += OnLoaded; }
public static void NavigateTo(UserControl page) { if (Window.Current.Content != null) { BackStack.Add(Window.Current.Content); } Window.Current.Content = page; Window.Current.Activate(); }
internal static void GoBack(UserControl control) { if (control == null) throw new ArgumentNullException("control"); if (control.Parent.GetType() == typeof(Popup)) { ((Popup)control.Parent).IsOpen = false; } SettingsPane.Show(); }
private Popup BuildSettingsItem(UserControl userControl, int width) { var popup = new Popup(); popup.IsLightDismissEnabled = true; userControl.Width = width; userControl.Height = Window.Current.Bounds.Height; popup.Child = userControl; popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - width); popup.SetValue(Canvas.TopProperty, 0); popup.IsOpen = true; return popup; }
private void OpenPopup(int width, UserControl child) { var settingsPopup = new Popup { IsLightDismissEnabled = true, Width = width, Height = Window.Current.Bounds.Height }; child.Width = width; child.Height = Window.Current.Bounds.Height; settingsPopup.Child = child; settingsPopup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - width); settingsPopup.SetValue(Canvas.TopProperty, 0); settingsPopup.IsOpen = true; }
public bool Navigate(UserControl page) { // TODO for better performance => create page (GetPage) after CallOnNavigatedFrom() call (performance). Problem: page in lambda not availalbe then var lastPage = CurrentPage; PageStack.Push(page); if (lastPage != null) return CallOnNavigatedFrom(lastPage, page); else { SetPage(page); CallOnNavigatedTo(page); return false; } }
/// <summary> /// Shows the given control in the flyout. /// </summary> public void ShowFlyout(UserControl control) { this.popup = new Popup(); //this.popup.Opened += OnPopupOpened; //this.popup.Closed += OnPopupClosed; this.popup.IsLightDismissEnabled = true; this.popup.Width = FlyoutWidth; this.popup.Height = Window.Current.Bounds.Height; control.Width = FlyoutWidth; control.Height = FlyoutHeight; this.popup.Child = control; this.popup.SetValue(Canvas.LeftProperty, FlyoutLeft); this.popup.SetValue(Canvas.TopProperty, FlyoutTop); this.popup.IsOpen = true; }
private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { this.currentItem = e.NavigationParameter as GridItem; this.pageTitle.Text = this.currentItem.Title; this.sampleLink.NavigateUri = this.currentItem.NavigationUrl; // Special case the app page for search. if (this.currentItem.ControlType.Name == "App") { this.currentControl = new SearchDemo(); } else { this.currentControl = (UserControl)Activator.CreateInstance(this.currentItem.ControlType); } this.detailGrid.Children.Add(this.currentControl); this.CodeViewButton.Content = CodeShowPage.seeTheCode; this.storageItems = new List<StorageFile>(); string xamlText = await this.GetFileText(CodeShowPage.pathToSourceCode + this.currentItem.ControlType.Name + ".xaml", true); string csText = await this.GetFileText(CodeShowPage.pathToSourceCode + this.currentItem.ControlType.Name + ".xaml.cs", true); if (!String.IsNullOrEmpty(this.currentItem.CsFileName)) { if (!String.IsNullOrWhiteSpace(csText)) { csText += "\r\nAdditional code from " + this.currentItem.CsFileName + "\r\n\r\n"; } csText += await this.GetFileText(CodeShowPage.pathToSourceCode + this.currentItem.CsFileName, true); } if (!String.IsNullOrEmpty(this.currentItem.XamlFileName)) { if (!String.IsNullOrWhiteSpace(xamlText)) { xamlText += "\r\nAdditional code from " + this.currentItem.XamlFileName + "\r\n\r\n"; } xamlText += await this.GetFileText(CodeShowPage.pathToSourceCode + this.currentItem.XamlFileName, true); } this.codeShowControl.ShowXamlText = xamlText; this.codeShowControl.ShowCsText = csText; }
public void RestoreSettings(ApplicationDataCompositeValue settings) { if (settings.ContainsKey("MenuButton")) { if (settings["MenuButton"] != null) { switch (settings["MenuButton"] as string) { case "Search": _lastButton = _searchButton; _lastPanel = _searchPanel; break; case "Bibles": _lastButton = _biblesButton; _lastPanel = _bibleListPanel; break; case "BibleBooks": _lastButton = _biblesBookButton; _lastPanel = _bibleBookListPanel; break; } _lastButton.IsChecked = true; _lastPanel.Visibility = Visibility.Visible; } } }
/// <summary> /// Display a user control inside a screen popup window /// </summary> /// <param name="control"></param> public void ShowFlyout(UserControl control) { _popup = new Popup(); _popup.Closed += OnPopupClosed; Window.Current.Activated += OnWindowActivated; _popup.IsLightDismissEnabled = true; _popup.Width = _width; _popup.Height = Window.Current.Bounds.Height; control.Width = _width; control.Height = Window.Current.Bounds.Height; _popup.Child = control; _popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - _width); _popup.SetValue(Canvas.TopProperty, 0); _popup.IsOpen = true; }
public static Popup Create(UserControl element, double width) { Popup p = new Popup(); p.Child = element; p.IsLightDismissEnabled = true; p.ChildTransitions = new TransitionCollection(); p.ChildTransitions.Add(new PaneThemeTransition() //声明边缘 UI(如应用程序栏)的边缘转换位置。 { Edge = (SettingsPane.Edge == SettingsEdgeLocation.Right) ? EdgeTransitionLocation.Right : EdgeTransitionLocation.Left });//检查SettingsPane的edge,有些国家的超级菜单在左边。 element.Width = width; element.Height = Window.Current.Bounds.Height; p.SetValue(Canvas.LeftProperty, SettingsPane.Edge == SettingsEdgeLocation.Right ? (Window.Current.Bounds.Width - width) : 0);//设置距离左边的边距 p.SetValue(Canvas.TopProperty, 0); return p; }
private Popup BuildSettingsItem(UserControl userControl, int width) { Popup popup = new Popup(); popup.IsLightDismissEnabled = true; popup.ChildTransitions = new TransitionCollection(); popup.ChildTransitions.Add(new PaneThemeTransition() { Edge = (SettingsPane.Edge == SettingsEdgeLocation.Right) ? EdgeTransitionLocation.Right : EdgeTransitionLocation.Left }); userControl.Width = width; userControl.Height = Window.Current.Bounds.Height; popup.Child = userControl; popup.SetValue(Canvas.LeftProperty, SettingsPane.Edge == SettingsEdgeLocation.Right ? (Window.Current.Bounds.Width - width) : 0); popup.SetValue(Canvas.TopProperty, 0); return popup; }
void _onSetLoader(object message) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var m = message as SetLoaderMessage; if (m != null) { var c = this.Content as Canvas; if (c != null) { if (_loader != null) { var cParent = _loader.Parent as Canvas; if (cParent != null) cParent.Children.Remove(_loader); _loader = null; } var newLoader = new LoaderOverlayView(); _loader = newLoader; c.Children.Add(newLoader); newLoader.SetValue(Canvas.LeftProperty, (c.ActualWidth - newLoader.Width)/2); newLoader.SetValue(Canvas.TopProperty, (c.ActualHeight - newLoader.Height)/2); } } else { if (_loader != null) { var cParent = _loader.Parent as Canvas; if (cParent != null) cParent.Children.Remove(_loader); _loader = null; } } }); }
public BasicStackedRowPercentageExample() { InitializeComponent(); SeriesCollection = new SeriesCollection { new StackedRowSeries { Values = new ChartValues<double> {4, 5, 6, 8}, StackMode = StackMode.Percentage, DataLabels = true, LabelPoint = p => p.X.ToString() }, new StackedRowSeries { Values = new ChartValues<double> {2, 5, 6, 7}, StackMode = StackMode.Percentage, DataLabels = true, LabelPoint = p => p.X.ToString() } }; //adding series updates and animates the chart SeriesCollection.Add(new StackedRowSeries { Values = new ChartValues<double> { 6, 2, 7 }, StackMode = StackMode.Percentage, DataLabels = true, LabelPoint = p => p.X.ToString() }); //adding values also updates and animates SeriesCollection[2].Values.Add(4d); Labels = new[] { "Chrome", "Mozilla", "Opera", "IE" }; Formatter = val => val.ToString("P"); this.Tooltip = new DefaultTooltip() { SelectionMode = TooltipSelectionMode.SharedYValues }; }
public virtual void Attach(DependencyObject associatedObject) { AssociatedObject = associatedObject; _associatedControl = AssociatedObject as UserControl; if (_associatedControl == null) { throw new InvalidOperationException( "OrientationStateControlBehavior can only be attached to a UserControl."); } Messenger.Default.Register<OrientationStateMessage>( this, HandleOrientationMessage); }
static public void ExampleControlCreated(string name, UserControl control) { if (control.GetType() == typeof(DeveloperTools)) return; exampleControls.Add(new KeyValuePair<string, WeakReference<UserControl>>(name, new WeakReference<UserControl>(control))); }
public void DisplayPage_SetsSettingsFlyoutHostContent() { TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(); UserControl page = new UserControl(); settingsPaneManager.CallDisplayPage(page); SettingsFlyout flyout = settingsPaneManager.ShowSettingsFlyoutCalls.First(); Assert.Equal(page, flyout.Content); }
public void DisplayPage_SetsSettingsFlyoutHeaderForeground() { TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(); Brush brush = new SolidColorBrush(); UserControl page = new UserControl(); SettingsPaneInfo.SetHeaderForeground(page, brush); settingsPaneManager.CallDisplayPage(page); SettingsFlyout flyout = settingsPaneManager.ShowSettingsFlyoutCalls.First(); Assert.Equal(brush, flyout.HeaderForeground); }
public void DisplayPage_SetsSettingsFlyoutIconSource() { TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(); ImageSource icon = new BitmapImage(); UserControl page = new UserControl(); SettingsPaneInfo.SetIconSource(page, icon); settingsPaneManager.CallDisplayPage(page); SettingsFlyout flyout = settingsPaneManager.ShowSettingsFlyoutCalls.First(); Assert.Equal(icon, flyout.IconSource); }
public void DisplayPage_WithSettingsFlyout_SetsSettingsFlyoutHostWidth() { TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(); UserControl page1 = new UserControl(); SettingsPaneInfo.SetWidth(page1, 420); settingsPaneManager.CallDisplayPage(page1); SettingsFlyout page2 = new SettingsFlyout() { Width = 500 }; settingsPaneManager.CallDisplayPage(page2); SettingsFlyout flyout = settingsPaneManager.ShowSettingsFlyoutCalls.First(); Assert.Equal(500, flyout.Width); }
public void DisplayPage_SetsSettingsFlyoutWidth() { TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(); UserControl page = new UserControl(); SettingsPaneInfo.SetWidth(page, 420); settingsPaneManager.CallDisplayPage(page); SettingsFlyout flyout = settingsPaneManager.ShowSettingsFlyoutCalls.First(); Assert.Equal(420, flyout.Width); }
public void DisplayPage_SetsSettingsFlyoutTitle() { TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(); UserControl page = new UserControl(); SettingsPaneInfo.SetTitle(page, "Test Title"); settingsPaneManager.CallDisplayPage(page); SettingsFlyout flyout = settingsPaneManager.ShowSettingsFlyoutCalls.First(); Assert.Equal("Test Title", flyout.Title); }
public void DisplayPage_UsesDefaultSettingsFlyoutTemplate() { TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(); UserControl page = new UserControl(); settingsPaneManager.CallDisplayPage(new SettingsFlyout()); settingsPaneManager.CallDisplayPage(page); SettingsFlyout flyout = settingsPaneManager.ShowSettingsFlyoutCalls.First(); Assert.Equal(null, flyout.Template); }
private void ShowSettingsFlyout(UserControl content) { settingsPopup = new Popup(); settingsPopup.Closed += popup_Closed; Window.Current.Activated += Current_Activated; settingsPopup.IsLightDismissEnabled = true; settingsPopup.Width = settingsFlyoutWidth; settingsPopup.Height = windowBounds.Height; settingsPopup.ChildTransitions = new TransitionCollection(); settingsPopup.ChildTransitions.Add(new PaneThemeTransition() { Edge = (SettingsPane.Edge == SettingsEdgeLocation.Right) ? EdgeTransitionLocation.Right : EdgeTransitionLocation.Left }); content.Width = settingsFlyoutWidth; content.Height = windowBounds.Height; settingsPopup.Child = content; settingsPopup.SetValue(Canvas.LeftProperty, SettingsPane.Edge == SettingsEdgeLocation.Right ? windowBounds.Width - settingsFlyoutWidth : 0); settingsPopup.SetValue(Canvas.TopProperty, 0); settingsPopup.IsOpen = true; }