Skip to content

Commit 135e3b5

Browse files
author
Anjali
authored
Adding win11 styles to RichTextBox and Separator (#8581)
* Adding win11 styles to RichTextBox and Separator * Changed the IsReadOnly flag to "False"
1 parent 989bbf8 commit 135e3b5

File tree

4 files changed

+136
-3
lines changed

4 files changed

+136
-3
lines changed

src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi
195195
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RadioButton' changed from '[LocalizabilityAttribute(9)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.RadioButton)]' in the implementation.
196196
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RadioButton.GroupName' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation.
197197
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RichTextBox' changed from '[LocalizabilityAttribute(15)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Inherit)]' in the implementation.
198+
MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.RichTextBox.IsTextSelectionEnabledProperty' does not exist in the implementation but it does exist in the contract.
198199
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.RichTextBox.CaretPosition' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
200+
MembersMustExist : Member 'public System.Boolean System.Windows.Controls.RichTextBox.IsTextSelectionEnabled.get()' does not exist in the implementation but it does exist in the contract.
201+
MembersMustExist : Member 'public void System.Windows.Controls.RichTextBox.IsTextSelectionEnabled.set(System.Boolean)' does not exist in the implementation but it does exist in the contract.
199202
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.ScrollContentPresenter.HorizontalOffset' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
200203
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.ScrollContentPresenter.ScrollOwner' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
201204
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.ScrollContentPresenter.VerticalOffset' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
@@ -355,6 +358,4 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi
355358
CannotChangeAttribute : Attribute 'System.Windows.Markup.DesignerSerializationOptionsAttribute' on 'System.Windows.Markup.XmlAttributeProperties.GetXmlSpace(System.Windows.DependencyObject)' changed from '[DesignerSerializationOptionsAttribute(1)]' in the contract to '[DesignerSerializationOptionsAttribute(DesignerSerializationOptions.SerializeAsAttribute)]' in the implementation.
356359
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Media.Animation.Storyboard.GetTarget(System.Windows.DependencyObject)' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
357360
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Shapes.Shape' changed from '[LocalizabilityAttribute(0, Readability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]' in the implementation.
358-
359-
Total Issues: 355
360-
361+
Total Issues: 359

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/RichTextBox.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,25 @@ public bool IsDocumentEnabled
521521
}
522522
}
523523

524+
/// <summary>
525+
/// Property for <see cref="IsTextSelectionEnabledProperty"/>.
526+
/// </summary>
527+
public static readonly DependencyProperty IsTextSelectionEnabledProperty = DependencyProperty.Register(
528+
nameof(IsTextSelectionEnabled),
529+
typeof(bool),
530+
typeof(RichTextBox),
531+
new PropertyMetadata(false)
532+
);
533+
534+
/// <summary>
535+
/// TODO
536+
/// </summary>
537+
public bool IsTextSelectionEnabled
538+
{
539+
get => (bool)GetValue(IsTextSelectionEnabledProperty);
540+
set => SetValue(IsTextSelectionEnabledProperty, value);
541+
}
542+
524543
// ...........................................................
525544
//
526545
// Content Accessing Properties
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<!--
2+
Based on Microsoft XAML for Win UI
3+
Copyright (c) Microsoft Corporation. All Rights Reserved.
4+
-->
5+
6+
<ResourceDictionary
7+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
8+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
9+
xmlns:controls="clr-namespace:System.Windows;assembly=PresentationFramework">
10+
11+
<Style x:Key="DefaultRichTextBoxStyle" TargetType="{x:Type RichTextBox}">
12+
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
13+
<Setter Property="CaretBrush" Value="{DynamicResource TextControlForeground}" />
14+
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
15+
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
16+
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
17+
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
18+
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
19+
<Setter Property="MinHeight" Value="34" />
20+
<Setter Property="BorderThickness" Value="1" />
21+
<Setter Property="Padding" Value="6,4" />
22+
<Setter Property="FontSize" Value="14" />
23+
<Setter Property="SnapsToDevicePixels" Value="True" />
24+
<Setter Property="OverridesDefaultStyle" Value="True" />
25+
<Setter Property="Template">
26+
<Setter.Value>
27+
<ControlTemplate TargetType="{x:Type RichTextBox}">
28+
<Border
29+
x:Name="MainBorder"
30+
Padding="0"
31+
Background="{TemplateBinding Background}"
32+
BorderBrush="{TemplateBinding BorderBrush}"
33+
BorderThickness="{TemplateBinding BorderThickness}"
34+
CornerRadius="4"
35+
Focusable="False">
36+
<ScrollViewer
37+
x:Name="PART_ContentHost"
38+
Margin="0,0,2,0"
39+
Padding="{TemplateBinding Padding}"
40+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
41+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
42+
Foreground="{TemplateBinding Foreground}"
43+
HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"
44+
VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}" />
45+
</Border>
46+
<ControlTemplate.Triggers>
47+
<MultiTrigger>
48+
<MultiTrigger.Conditions>
49+
<Condition Property="IsEnabled" Value="True" />
50+
<Condition Property="IsMouseOver" Value="True" />
51+
<Condition Property="IsFocused" Value="False" />
52+
</MultiTrigger.Conditions>
53+
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
54+
</MultiTrigger>
55+
<Trigger Property="IsFocused" Value="True">
56+
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
57+
</Trigger>
58+
</ControlTemplate.Triggers>
59+
</ControlTemplate>
60+
</Setter.Value>
61+
</Setter>
62+
</Style>
63+
64+
<Style
65+
x:Key="DefaultUiRichTextBoxStyle"
66+
BasedOn="{StaticResource DefaultRichTextBoxStyle}"
67+
TargetType="{x:Type RichTextBox}">
68+
69+
<Style.Triggers>
70+
<Trigger Property="TextBox.IsTextSelectionEnabled" Value="True">
71+
<Setter Property="IsReadOnly" Value="False" />
72+
<Setter Property="Background" Value="Transparent" />
73+
<Setter Property="Padding" Value="0" />
74+
<Setter Property="BorderBrush" Value="Transparent" />
75+
<Setter Property="BorderThickness" Value="0" />
76+
</Trigger>
77+
</Style.Triggers>
78+
</Style>
79+
80+
<Style BasedOn="{StaticResource DefaultUiRichTextBoxStyle}" TargetType="{x:Type RichTextBox}" />
81+
82+
83+
</ResourceDictionary>
84+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
Based on Microsoft XAML for Win UI
3+
Copyright (c) Microsoft Corporation. All Rights Reserved.
4+
-->
5+
6+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
7+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
8+
<Style TargetType="{x:Type Separator}">
9+
<Setter Property="BorderBrush" Value="{DynamicResource SeparatorBorderBrush}" />
10+
<Setter Property="Background" Value="Transparent" />
11+
<Setter Property="Margin" Value="0" />
12+
<Setter Property="BorderThickness" Value="1,1,0,0" />
13+
<Setter Property="Focusable" Value="False" />
14+
<Setter Property="SnapsToDevicePixels" Value="True" />
15+
<Setter Property="OverridesDefaultStyle" Value="True" />
16+
<Setter Property="Template">
17+
<Setter.Value>
18+
<ControlTemplate TargetType="{x:Type Separator}">
19+
<Border
20+
Width="{TemplateBinding Width}"
21+
Margin="{TemplateBinding Margin}"
22+
Background="{TemplateBinding Background}"
23+
BorderBrush="{TemplateBinding BorderBrush}"
24+
BorderThickness="{TemplateBinding BorderThickness}" />
25+
</ControlTemplate>
26+
</Setter.Value>
27+
</Setter>
28+
</Style>
29+
</ResourceDictionary>

0 commit comments

Comments
 (0)