public CompactOverlay_HomePage() { ViewModel = new CompactOverlay_HomePageViewModel(); this.InitializeComponent(); Current = this; DataContext = ViewModel; #region 标题栏设置 Title Bar Setting CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; //扩展标题栏 Window.Current.SetTitleBar(TitleBar); //设置某个容器空间(我一般就用的Grid)为标题栏,即可拖拽来位移窗体 //注意:该控件必须要有颜色,哪怕是Transparent透明也行。如果不设置background,它就是空的没法进行拖拽。 var view = ApplicationView.GetForCurrentView(); //来进行以下一系列设置标题栏组件颜色的操作 view.TitleBar.ButtonBackgroundColor = Color.FromArgb(0, 0, 0, 0); view.TitleBar.ButtonForegroundColor = Colors.White; view.TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(38, 0, 0, 0); view.TitleBar.ButtonHoverForegroundColor = Colors.White; view.TitleBar.ButtonPressedBackgroundColor = Color.FromArgb(70, 0, 0, 0); view.TitleBar.ButtonPressedForegroundColor = Colors.White; view.TitleBar.ButtonInactiveBackgroundColor = Color.FromArgb(0, 0, 0, 0); view.TitleBar.ButtonInactiveForegroundColor = Colors.Gray; #endregion var changed = Observable.FromEventPattern <TypedEventHandler <AutoSuggestBox, AutoSuggestBoxTextChangedEventArgs>, AutoSuggestBox, AutoSuggestBoxTextChangedEventArgs>( handler => AutoSuggestBox.TextChanged += handler, handler => AutoSuggestBox.TextChanged -= handler); var input = changed .DistinctUntilChanged(temp => temp.Sender.Text) .Throttle(TimeSpan.FromMilliseconds(200)); var userInput = input .ObserveOnDispatcher() .Where(temp => temp.EventArgs.Reason == AutoSuggestionBoxTextChangeReason.UserInput) //.Where(temp => !string.IsNullOrEmpty(temp.Sender.Text)) .Select(async temp => await ViewModel.UpdateSuggestionListAsync(temp.Sender.Text)); var notUserInput = input .ObserveOnDispatcher() .Where(temp => temp.EventArgs.Reason == AutoSuggestionBoxTextChangeReason.ProgrammaticChange) .Select(temp => Task.FromResult <List <WordSuggestionViewModel> >(null));; var merge = Observable .Merge(notUserInput, userInput); merge .ObserveOnDispatcher() .Subscribe(async suggestions => { AutoSuggestBox.ItemsSource = await suggestions; }); }
private void NotificationBarClose_Completed(object sender, object e) { CompactOverlay_HomePage.Remove_Notification(this); }