CmdPal: Expand Binding markup extensions to nested elements to avoid WMC1510 (#45830)

## Summary of the Pull Request

This PR expands all Binding XAML markup expressions to nested elements,
which in turn prevents compiler from generating `WMC1510 Ensure the
property path is trimming and AOT compatible` warnings.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Related to: #42574
This commit is contained in:
Jiří Polášek
2026-03-03 11:46:23 +01:00
committed by GitHub
parent 798564eea4
commit 9089ca2ede
5 changed files with 112 additions and 17 deletions

View File

@@ -257,13 +257,29 @@
<VisualState x:Name="HeroContentTop">
<VisualState.Setters>
<Setter Target="HeroContentBorder.(Grid.Row)" Value="0" />
<Setter Target="HeroContentBorder.CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}, FallbackValue=0}" />
<Setter Target="HeroContentBorder.CornerRadius">
<Setter.Value>
<Binding
Converter="{StaticResource TopCornerRadiusFilterConverter}"
FallbackValue="0"
Path="CornerRadius"
RelativeSource="{RelativeSource TemplatedParent}" />
</Setter.Value>
</Setter>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="HeroContentBottom">
<VisualState.Setters>
<Setter Target="HeroContentBorder.(Grid.Row)" Value="2" />
<Setter Target="HeroContentBorder.CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}, FallbackValue=0}" />
<Setter Target="HeroContentBorder.CornerRadius">
<Setter.Value>
<Binding
Converter="{StaticResource BottomCornerRadiusFilterConverter}"
FallbackValue="0"
Path="CornerRadius"
RelativeSource="{RelativeSource TemplatedParent}" />
</Setter.Value>
</Setter>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>

View File

@@ -158,12 +158,24 @@
Grid.ColumnSpan="1"
Margin="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
Foreground="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={ThemeResource TextControlPlaceholderForeground}}"
IsHitTestVisible="False"
Text="{TemplateBinding PlaceholderText}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
Visibility="{Binding Description, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ReverseStringVisibilityConverter}, Mode=OneWay}" />
TextWrapping="{TemplateBinding TextWrapping}">
<TextBlock.Visibility>
<Binding
Converter="{StaticResource ReverseStringVisibilityConverter}"
Mode="OneWay"
Path="Description"
RelativeSource="{RelativeSource TemplatedParent}" />
</TextBlock.Visibility>
<TextBlock.Foreground>
<Binding
Path="PlaceholderForeground"
RelativeSource="{RelativeSource TemplatedParent}"
TargetNullValue="{ThemeResource TextControlPlaceholderForeground}" />
</TextBlock.Foreground>
</TextBlock>
<Button
x:Name="DeleteButton"
Grid.Column="2"
@@ -188,9 +200,15 @@
CharacterSpacing="15"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
Foreground="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={ThemeResource TextControlPlaceholderForeground}}"
Text="{TemplateBinding Description}"
TextWrapping="{TemplateBinding TextWrapping}" />
TextWrapping="{TemplateBinding TextWrapping}">
<TextBlock.Foreground>
<Binding
Path="PlaceholderForeground"
RelativeSource="{RelativeSource TemplatedParent}"
TargetNullValue="{ThemeResource TextControlPlaceholderForeground}" />
</TextBlock.Foreground>
</TextBlock>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
@@ -212,7 +230,14 @@
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={ThemeResource TextControlPlaceholderForegroundDisabled}}" />
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Binding
Path="PlaceholderForeground"
RelativeSource="{RelativeSource TemplatedParent}"
TargetNullValue="{ThemeResource TextControlPlaceholderForegroundDisabled}" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
@@ -225,20 +250,41 @@
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>-->
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={ThemeResource TextControlPlaceholderForegroundPointerOver}}" />
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Binding
Path="PlaceholderForeground"
RelativeSource="{RelativeSource TemplatedParent}"
TargetNullValue="{ThemeResource TextControlPlaceholderForegroundPointerOver}" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DescriptionPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={ThemeResource TextControlPlaceholderForegroundPointerOver}}" />
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Binding
Path="PlaceholderForeground"
RelativeSource="{RelativeSource TemplatedParent}"
TargetNullValue="{ThemeResource TextControlPlaceholderForegroundPointerOver}" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Focused">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={ThemeResource TextControlPlaceholderForegroundFocused}}" />
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Binding
Path="PlaceholderForeground"
RelativeSource="{RelativeSource TemplatedParent}"
TargetNullValue="{ThemeResource TextControlPlaceholderForegroundFocused}" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundFocused}" />
@@ -253,7 +299,14 @@
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DescriptionPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding PlaceholderForeground, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={ThemeResource TextControlPlaceholderForegroundFocused}}" />
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Binding
Path="PlaceholderForeground"
RelativeSource="{RelativeSource TemplatedParent}"
TargetNullValue="{ThemeResource TextControlPlaceholderForegroundFocused}" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>