Skip to content

Commit

Permalink
Use accessible Foreground on WatermarkedTextbox in Add Package Source…
Browse files Browse the repository at this point in the history
… Mapping Dialog (#4856)
  • Loading branch information
donnie-msft authored Oct 17, 2022
1 parent 6a986d7 commit 10ce64e
Showing 1 changed file with 46 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,47 @@
<Style TargetType="ScrollBar">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ScrollBarColorKey}}"/>
</Style>
<!-- Copied from ThemedDialogResources.xaml. See https://github.com/NuGet/Home/issues/12163 -->
<Style TargetType="{x:Type vsui:WatermarkedTextBox}">
<Setter Property="Padding" Value="6,8,6,8" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Watermark}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type vsui:WatermarkedTextBox}">
<Border x:Name="border"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True">
<Grid>
<ScrollViewer x:Name="PART_ContentHost"
Padding="{TemplateBinding Padding}"
Focusable="false"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"/>
<TextBlock VerticalAlignment="Center"
x:Name="WatermarkTextBlock"
Visibility="Collapsed"
Cursor="IBeam"
Padding="{TemplateBinding Padding}"
Margin="2,0,0,0"
Text="{TemplateBinding Watermark}"
IsHitTestVisible="False"
Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
</Trigger>
<Trigger Property="Text" Value="">
<Setter TargetName="WatermarkTextBlock" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<StackPanel Grid.Row="0">
<Grid>
Expand Down Expand Up @@ -63,18 +104,18 @@
<StackPanel Grid.Row="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="48"/>
<RowDefinition Height="*"/>
<RowDefinition Height="36"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<vsui:WatermarkedTextBox Grid.Row="0"
BorderBrush="{DynamicResource {x:Static vsui:CommonControlsColors.ButtonBorderBrushKey}}"
BorderThickness="1"
AutomationProperties.Name="{x:Static nuget:Resources.VSOptions_Watermark_AddPackageNamespace}"
x:Name="_packageID"
MaxLength="100"
Margin="12,6,12,6"
Watermark="{x:Static nuget:Resources.VSOptions_Watermark_AddPackageNamespace}"
Foreground="{Binding Path=(TextElement.Foreground), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
Background="{Binding Path=(Window.Background), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
TextChanged="PackageID_TextChanged"/>
<StackPanel Orientation="Vertical" Grid.Row="1">
<nuget:ProjectsListView AutomationProperties.Name="{x:Static nuget:Resources.VSOptions_Accessibility_SourcesList}"
Expand Down

0 comments on commit 10ce64e

Please sign in to comment.