static void OnTreeViewItemSelected(object sender, RoutedEventArgs e) { // Only react to the Selected event raised by the TreeViewItem // whose IsSelected property was modified. Ignore all ancestors // who are merely reporting that a descendant's Selected fired. if (!Object.ReferenceEquals(sender, e.OriginalSource)) { return; } TreeViewItem item = e.OriginalSource as TreeViewItem; if (item != null) { item.BringIntoView(); FocusHelper.Focus(item); } }
private void OnMouseLeftButtonUp_TextBox(object sender, MouseButtonEventArgs e) { FocusHelper.Focus(this); }
private void OnWindowLoaded(object sender, RoutedEventArgs e) { if (Owner != null) { //Owner.ForceCursor = true; Owner.Cursor = Cursors.Arrow; this.Cursor = Cursors.Arrow; } #if NET40 this.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal); this.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.Auto); this.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Fixed); #endif //NET40 Console.WriteLine(@"Popup WpfSoftwareRender => " + Tobi.Common.Settings.Default.WpfSoftwareRender); if (Tobi.Common.Settings.Default.WpfSoftwareRender) { var hwndSource = PresentationSource.FromVisual(this) as HwndSource; if (hwndSource != null) { HwndTarget hwndTarget = hwndSource.CompositionTarget; hwndTarget.RenderMode = RenderMode.SoftwareOnly; } } //0 => No graphics hardware acceleration available for the application on the device. //1 => Partial graphics hardware acceleration available on the video card. This corresponds to a DirectX version that is greater than or equal to 7.0 and less than 9.0. //2 => A rendering tier value of 2 means that most of the graphics features of WPF should use hardware acceleration provided the necessary system resources have not been exhausted. This corresponds to a DirectX version that is greater than or equal to 9.0. int renderingTier = (RenderCapability.Tier >> 16); Console.WriteLine(@"Popup RenderCapability.Tier => " + renderingTier); try { //Uri iconUri = new Uri("Tobi.ico", UriKind.RelativeOrAbsolute); //Uri iconUri = new Uri("pack://application:,,,/Tobi;component/Tobi.ico", UriKind.Absolute); string appFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string iconPath = Path.Combine(appFolder, "Shortcut.ico"); var iconUri = new Uri("file://" + iconPath, UriKind.Absolute); Icon = BitmapFrame.Create(iconUri); } finally { //ignore } OnPropertyChangedButtonsSet(); Button buttonToFocus = ButtonOK; switch (DefaultDialogButton) { case DialogButton.Yes: { buttonToFocus = ButtonYes; break; } case DialogButton.Ok: { buttonToFocus = ButtonOK; break; } case DialogButton.No: { buttonToFocus = ButtonNo; break; } case DialogButton.Close: { buttonToFocus = ButtonClose; break; } case DialogButton.Cancel: { buttonToFocus = ButtonCancel; break; } case DialogButton.Apply: { buttonToFocus = ButtonApply; break; } } FocusHelper.Focus(buttonToFocus); }