diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEventArgs.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEventArgs.cs index bdede7f206a..64b1f340ddd 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEventArgs.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEventArgs.cs @@ -1,8 +1,9 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Specialized; using MS.Internal; +using MS.Internal.KnownBoxes; namespace System.Windows { @@ -135,7 +136,7 @@ public bool Handled { TraceRoutedEvent.TraceActivityItem( TraceRoutedEvent.HandleEvent, - value, + BooleanBoxes.Box(value), RoutedEvent.OwnerType.Name, RoutedEvent.Name, this ); @@ -289,7 +290,6 @@ protected virtual void InvokeEventHandler(Delegate genericHandler, object generi } else { - // Restricted Action - reflection permission required genericHandler.DynamicInvoke(new object[] {genericTarget, this}); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/UIElement.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/UIElement.cs index 5c67a74dec6..6a5d7f63a32 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/UIElement.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/UIElement.cs @@ -2247,7 +2247,7 @@ private static void ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args args.RoutedEvent, sender, args, - args.Handled ); + BooleanBoxes.Box(args.Handled)); } try @@ -2275,7 +2275,7 @@ private static void ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args args.RoutedEvent, sender, args, - args.Handled ); + BooleanBoxes.Box(args.Handled)); } } @@ -2299,7 +2299,7 @@ internal static void RaiseEventImpl(DependencyObject sender, RoutedEventArgs arg args.RoutedEvent, sender, args, - args.Handled ); + BooleanBoxes.Box(args.Handled)); } try @@ -2325,7 +2325,7 @@ internal static void RaiseEventImpl(DependencyObject sender, RoutedEventArgs arg args.RoutedEvent, sender, args, - args.Handled ); + BooleanBoxes.Box(args.Handled)); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/AccessText.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/AccessText.cs index f41f7526bdc..94ba08ee5e6 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/AccessText.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/AccessText.cs @@ -12,6 +12,7 @@ using System.Xml; using MS.Internal; +using MS.Internal.KnownBoxes; namespace System.Windows.Controls { @@ -555,7 +556,7 @@ private static Style AccessKeyStyle Trigger trigger = new Trigger { Property = KeyboardNavigation.ShowKeyboardCuesProperty, - Value = true + Value = BooleanBoxes.TrueBox }; trigger.Setters.Add(new Setter(TextDecorationsProperty, System.Windows.TextDecorations.Underline)); accessKeyStyle.Triggers.Add(trigger); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ComboBox.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ComboBox.cs index 931135c26c3..d04c4997370 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ComboBox.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ComboBox.cs @@ -484,8 +484,9 @@ private static object CoerceIsSelectionBoxHighlighted(object o, object value) { ComboBox comboBox = (ComboBox)o; ComboBoxItem highlightedElement; - return (!comboBox.IsDropDownOpen && comboBox.IsKeyboardFocusWithin) || - ((highlightedElement = comboBox.HighlightedElement) != null && highlightedElement.Content == comboBox._clonedElement); + + return BooleanBoxes.Box((!comboBox.IsDropDownOpen && comboBox.IsKeyboardFocusWithin) || + ((highlightedElement = comboBox.HighlightedElement) != null && highlightedElement.Content == comboBox._clonedElement)); } #endregion diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridColumn.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridColumn.cs index 7359a2f54a1..68af4d94963 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridColumn.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridColumn.cs @@ -7,6 +7,7 @@ using System.Windows.Data; using System.Windows.Input; using MS.Internal; +using MS.Internal.KnownBoxes; namespace System.Windows.Controls { @@ -1271,19 +1272,8 @@ private static object OnCoerceIsFrozen(DependencyObject d, object baseValue) { DataGridColumn column = (DataGridColumn)d; DataGrid dataGrid = column.DataGridOwner; - if (dataGrid != null) - { - if (column.DisplayIndex < dataGrid.FrozenColumnCount) - { - return true; - } - else - { - return false; - } - } - return baseValue; + return dataGrid is null ? baseValue : BooleanBoxes.Box(column.DisplayIndex < dataGrid.FrozenColumnCount); } #endregion diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ItemsPanelTemplate.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ItemsPanelTemplate.cs index 6e6a7412fbf..ff201cfba27 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ItemsPanelTemplate.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ItemsPanelTemplate.cs @@ -6,6 +6,8 @@ // that manages layout of containers for an ItemsControl. // +using MS.Internal.KnownBoxes; + namespace System.Windows.Controls { /// @@ -124,7 +126,7 @@ internal override void ProcessTemplateBeforeSeal() if (!typeof(Panel).IsAssignableFrom(root.Type)) throw new InvalidOperationException(SR.Format(SR.ItemsPanelNotAPanel, root.Type)); - root.SetValue(Panel.IsItemsHostProperty, true); + root.SetValue(Panel.IsItemsHostProperty, BooleanBoxes.TrueBox); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/VirtualizingPanel.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/VirtualizingPanel.cs index 78f6702044c..9f409a76a44 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/VirtualizingPanel.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/VirtualizingPanel.cs @@ -6,6 +6,7 @@ using System.Collections.Specialized; using System.Windows.Media; using System.Windows.Controls.Primitives; // IItemContainerGenerator +using MS.Internal.KnownBoxes; namespace System.Windows.Controls { @@ -333,7 +334,8 @@ private static bool ValidateCacheSizeBeforeOrAfterViewport(object value) private static object CoerceIsVirtualizingWhenGrouping(DependencyObject d, object baseValue) { bool isVirtualizing = GetIsVirtualizing(d); - return isVirtualizing && (bool)baseValue; + + return BooleanBoxes.Box(isVirtualizing && (bool)baseValue); } internal static void OnVirtualizationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/CollectionViewSource.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/CollectionViewSource.cs index 02052fd9fdf..ce2acf4c48d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/CollectionViewSource.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/CollectionViewSource.cs @@ -11,11 +11,12 @@ using System.Collections; // IEnumerable using System.Collections.ObjectModel; // ObservableCollection using System.Collections.Specialized; // NotifyCollectionChanged* -using System.Globalization; // CultureInfo using System.ComponentModel; // ICollectionView +using System.Globalization; // CultureInfo using System.Windows.Markup; // XmlLanguage using MS.Internal; // Invariant.Assert using MS.Internal.Data; // DataBindEngine +using MS.Internal.KnownBoxes; namespace System.Windows.Data { @@ -329,7 +330,7 @@ public static readonly DependencyProperty IsLiveSortingProperty public bool? IsLiveSorting { get { return (bool?)GetValue(IsLiveSortingProperty); } - private set { SetValue(IsLiveSortingPropertyKey, value); } + private set { SetValue(IsLiveSortingPropertyKey, BooleanBoxes.Box(value)); } } /// @@ -452,7 +453,7 @@ public static readonly DependencyProperty IsLiveFilteringProperty public bool? IsLiveFiltering { get { return (bool?)GetValue(IsLiveFilteringProperty); } - private set { SetValue(IsLiveFilteringPropertyKey, value); } + private set { SetValue(IsLiveFilteringPropertyKey, BooleanBoxes.Box(value)); } } /// @@ -573,7 +574,7 @@ public static readonly DependencyProperty IsLiveGroupingProperty public bool? IsLiveGrouping { get { return (bool?)GetValue(IsLiveGroupingProperty); } - private set { SetValue(IsLiveGroupingPropertyKey, value); } + private set { SetValue(IsLiveGroupingPropertyKey, BooleanBoxes.Box(value)); } } ///