Files
ThreadPilot/Views/ProcessPowerPlanAssociationView.xaml
T
PrimeBuild-pc 5ef9766cd6 feat: edit and disable a saved rule without re-creating it
Saved rules could only be created and deleted. Changing one meant going back
to the Process tab and re-saving it, and there was no way to park a rule
without losing it.

The saved-rules list now has an editor beside it for everything that does not
need the core picker: enabled, CPU priority, memory priority, I/O priority,
assignment mode, and keeping the system awake. The core selection stays in the
Process tab and the panel says so, rather than offering a worse second picker.

UpdateRuleAsync carries the affinity payload through untouched and derives the
ApplyXOnStart flags from the values, so setting a priority back to None really
does stop the rule applying one. Realtime is refused there as it is everywhere
else, and is absent from the list rather than offered and then rejected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 23:38:13 +02:00

517 lines
34 KiB
XML

<UserControl x:Class="ThreadPilot.Views.ProcessPowerPlanAssociationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:converters="clr-namespace:ThreadPilot.Converters"
xmlns:local="clr-namespace:ThreadPilot.Views"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="1200">
<UserControl.Resources>
<converters:BoolToColorConverter x:Key="BoolToColorConverter"/>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<converters:InverseBooleanConverter x:Key="InverseBoolConverter"/>
</UserControl.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Standardized Header -->
<StackPanel Grid.Row="0" Margin="0,0,0,16">
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_Title}" Style="{StaticResource PageTitleTextStyle}" Margin="0,0,0,4"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_RulesDescription}"
Style="{StaticResource PageSubtitleTextStyle}"/>
</StackPanel>
<!-- Main Content -->
<TabControl Grid.Row="1" Background="{DynamicResource SurfaceBrush}" BorderThickness="0">
<TabControl.Resources>
<Style TargetType="TabItem">
<Setter Property="Padding" Value="14,7"/>
<Setter Property="Margin" Value="0,0,8,0"/>
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border x:Name="TabBorder"
Background="{DynamicResource ControlFillColorSecondaryBrush}"
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="8"
Padding="{TemplateBinding Padding}"
Margin="{TemplateBinding Margin}">
<ContentPresenter ContentSource="Header"
HorizontalAlignment="Center"
VerticalAlignment="Center"
TextElement.Foreground="{TemplateBinding Foreground}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="TabBorder" Property="Background" Value="{DynamicResource SoftSelectionBackgroundBrush}"/>
<Setter TargetName="TabBorder" Property="BorderBrush" Value="{DynamicResource SoftSelectionBorderBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.Resources>
<!-- Rules Tab -->
<TabItem Header="{DynamicResource ProcessPowerPlanAssociationView_RulesHeader}">
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Rules List -->
<GroupBox Grid.Column="0" Header="{DynamicResource ProcessPowerPlanAssociationView_CurrentRules}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<DataGrid Grid.Row="0"
ItemsSource="{Binding Associations}"
SelectedItem="{Binding SelectedAssociation}"
AutoGenerateColumns="False"
CanUserAddRows="False"
GridLinesVisibility="Horizontal"
HeadersVisibility="Column"
BorderThickness="1">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="{DynamicResource MasksView_Enabled}"
Binding="{Binding IsEnabled}"
Width="60"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_Executable}"
Binding="{Binding ExecutableName}"
Width="150"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_PowerPlan}"
Binding="{Binding PowerPlanName}"
Width="120"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_CpuMask}"
Binding="{Binding CoreMaskName}"
Width="100"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_Priority}"
Binding="{Binding ProcessPriority}"
Width="80"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_RulePriority}"
Binding="{Binding Priority}"
Width="60"/>
<DataGridCheckBoxColumn Header="{DynamicResource ProcessPowerPlanAssociationView_MatchByPath}"
Binding="{Binding MatchByPath}"
Width="100"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_Description}"
Binding="{Binding Description}"
Width="*"/>
</DataGrid.Columns>
</DataGrid>
<Border Grid.Row="0"
Padding="18"
IsHitTestVisible="False"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Associations.Count}" Value="0">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<StackPanel>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_NoRules}"
FontWeight="SemiBold"
HorizontalAlignment="Center"
Margin="0,0,0,4"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_EditorSubtitle}"
Foreground="{DynamicResource TextSecondaryBrush}"
TextWrapping="Wrap"
TextAlignment="Center"
MaxWidth="360"/>
</StackPanel>
</Border>
<StackPanel Grid.Row="1" Orientation="Horizontal"
HorizontalAlignment="Right" Margin="0,10,0,0">
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_Update}"
Command="{Binding UpdateAssociationCommand}"
Margin="0,0,5,0" Padding="10,5"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_UpdateRuleTooltip}"/>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_Remove}"
Command="{Binding RemoveAssociationCommand}"
Padding="10,5"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_RemoveTooltip}"/>
</StackPanel>
</Grid>
</GroupBox>
<!-- Rule Editor -->
<GroupBox Grid.Column="2" Header="{DynamicResource ProcessPowerPlanAssociationView_RuleEditor}">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>
<!-- Executable Selection Section -->
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_ExecutableMatch}" FontWeight="SemiBold" Margin="0,0,0,5"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_ExecutableHelp}"
Foreground="{DynamicResource TextSecondaryBrush}"
FontSize="10"
TextWrapping="Wrap"
Margin="0,0,0,8"/>
<!-- Browse Button -->
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_Browse}"
Command="{Binding BrowseExecutableCommand}"
Padding="10,8" Margin="0,0,0,10"
HorizontalAlignment="Left"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_BrowseTooltip}"/>
<!-- Selected Executable Display -->
<Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
Background="{DynamicResource SurfaceAltBrush}" Padding="8" Margin="0,0,0,10"
Visibility="{Binding HasSelectedExecutable, Converter={StaticResource BoolToVisibilityConverter}}">
<StackPanel>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_SelectedExecutable}" FontSize="10" Foreground="{DynamicResource TextSecondaryBrush}" Margin="0,0,0,2"/>
<TextBlock Text="{Binding SelectedExecutableDisplayName}"
FontWeight="SemiBold" Margin="0,0,0,2"/>
<TextBlock Text="{Binding SelectedExecutableFullPath}"
FontSize="10" Foreground="{DynamicResource TextSecondaryBrush}" TextWrapping="Wrap"/>
</StackPanel>
</Border>
<!-- Clear Selection Button -->
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_ClearSelection}"
Command="{Binding ClearSelectedExecutableCommand}"
Padding="5,3" Margin="0,0,0,15"
HorizontalAlignment="Left" FontSize="10"
Visibility="{Binding HasSelectedExecutable, Converter={StaticResource BoolToVisibilityConverter}}"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_ClearSelectionTooltip}"/>
<CheckBox Content="{DynamicResource ProcessPowerPlanAssociationView_MatchByPath}"
IsChecked="{Binding MatchByPath}"
Margin="0,0,0,10"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_MatchByPathTooltip}"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_RulePowerPlan}" Margin="0,0,0,5" FontWeight="SemiBold"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_RulePowerPlanHelp}"
Foreground="{DynamicResource TextSecondaryBrush}"
FontSize="10"
TextWrapping="Wrap"
Margin="0,0,0,5"/>
<ComboBox ItemsSource="{Binding AvailablePowerPlans}"
SelectedItem="{Binding SelectedPowerPlan}"
DisplayMemberPath="Name"
Padding="5" Margin="0,0,0,10"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_RuleCpuMask}" Margin="0,0,0,5"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_AppliedOnlyToMatching}"
Foreground="{DynamicResource TextSecondaryBrush}"
FontSize="10"
TextWrapping="Wrap"
Margin="0,0,0,5"/>
<ComboBox ItemsSource="{Binding AvailableCoreMasks}"
SelectedItem="{Binding SelectedCoreMask}"
DisplayMemberPath="Name"
Padding="5" Margin="0,0,0,10"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_RuleCpuMaskHelp}"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_ProcessPriority}" Margin="0,0,0,5"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_AppliedToMatching}"
Foreground="{DynamicResource TextSecondaryBrush}"
FontSize="10"
TextWrapping="Wrap"
Margin="0,0,0,5"/>
<ComboBox ItemsSource="{Binding AvailablePriorities}"
SelectedItem="{Binding SelectedProcessPriority}"
Padding="5" Margin="0,0,0,10"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_RulePriorityHelp}"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_AssociationPriority}" Margin="0,0,0,5"/>
<TextBox Text="{Binding Priority}"
Padding="5" Margin="0,0,0,10"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_AssociationPriorityHelp}"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_DescriptionLabel}" Margin="0,0,0,5"/>
<TextBox Text="{Binding Description}"
Padding="5" Margin="0,0,0,15"/>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_AddRule}"
Command="{Binding AddAssociationCommand}"
Padding="10,8"/>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_UpdateRule}"
Command="{Binding UpdateAssociationCommand}"
Padding="10,8"
Margin="0,8,0,0"/>
<Separator Margin="0,15,0,15"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_UseRunningProcess}"
FontWeight="SemiBold" Margin="0,0,0,10"/>
<ComboBox ItemsSource="{Binding RunningProcesses}"
SelectedItem="{Binding SelectedProcess}"
DisplayMemberPath="Name"
Padding="5" Margin="0,0,0,10"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_UseRunningProcessTooltip}"/>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_UseSelectedProcess}"
Command="{Binding UseSelectedProcessForAssociationCommand}"
Padding="10,5"
ToolTip="{DynamicResource ProcessPowerPlanAssociationView_UseSelectedProcessTooltip}"/>
</StackPanel>
</ScrollViewer>
</GroupBox>
</Grid>
</TabItem>
<!-- Saved Process Rules Tab -->
<TabItem Header="{DynamicResource ProcessPowerPlanAssociationView_SavedRulesHeader}">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Text="{DynamicResource ProcessPowerPlanAssociationView_SavedRulesDescription}"
Foreground="{DynamicResource TextSecondaryBrush}"
TextWrapping="Wrap"
Margin="0,0,0,10"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<DataGrid Grid.Column="0"
ItemsSource="{Binding SavedProcessRules}"
SelectedItem="{Binding SelectedSavedProcessRule, Mode=TwoWay}"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
GridLinesVisibility="Horizontal"
HeadersVisibility="Column"
BorderThickness="1">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="{DynamicResource MasksView_Enabled}"
Binding="{Binding IsEnabled}"
Width="60"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleProcess}"
Binding="{Binding ProcessName}"
Width="150"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleApplies}"
Binding="{Binding Applies}"
Width="*"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleMode}"
Binding="{Binding Mode}"
Width="110"/>
<DataGridTextColumn Header="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleUpdated}"
Binding="{Binding UpdatedAt}"
Width="140"/>
<DataGridTemplateColumn Width="90">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleDelete}"
Padding="8,2"
Margin="2"
Command="{Binding DataContext.DeleteSavedProcessRuleCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
CommandParameter="{Binding}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<GroupBox Grid.Column="2"
Width="330"
Header="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleEditor}"
VerticalAlignment="Top">
<StackPanel IsEnabled="{Binding SelectedSavedProcessRule, Converter={StaticResource NullToBoolConverter}}">
<TextBlock Text="{Binding SelectedSavedProcessRule.ProcessName}"
FontWeight="SemiBold"
Margin="0,0,0,8"/>
<CheckBox Content="{DynamicResource MasksView_Enabled}"
IsChecked="{Binding SavedRuleIsEnabled, Mode=TwoWay}"
Margin="0,0,0,10"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleCpuPriority}" Margin="0,0,0,3"/>
<ComboBox ItemsSource="{Binding SavedRulePriorityOptions}"
SelectedItem="{Binding SavedRulePriority, Mode=TwoWay}"
Margin="0,0,0,10"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleMemoryPriority}" Margin="0,0,0,3"/>
<ComboBox ItemsSource="{Binding SavedRuleMemoryPriorityOptions}"
SelectedItem="{Binding SavedRuleMemoryPriority, Mode=TwoWay}"
Margin="0,0,0,10"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleIoPriority}" Margin="0,0,0,3"/>
<ComboBox ItemsSource="{Binding SavedRuleIoPriorityOptions}"
SelectedItem="{Binding SavedRuleIoPriority, Mode=TwoWay}"
Margin="0,0,0,10"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleModeLabel}" Margin="0,0,0,3"/>
<ComboBox ItemsSource="{Binding SavedRuleCpuAssignmentModeOptions}"
SelectedItem="{Binding SavedRuleCpuAssignmentMode, Mode=TwoWay}"
Margin="0,0,0,10"/>
<CheckBox Content="{DynamicResource ProcessPowerPlanAssociationView_SavedRulePreventSleep}"
IsChecked="{Binding SavedRulePreventSleep, Mode=TwoWay}"
Margin="0,0,0,10"/>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleEditorHint}"
Foreground="{DynamicResource TextSecondaryBrush}"
TextWrapping="Wrap"
Margin="0,0,0,10"/>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_SavedRuleSave}"
Command="{Binding SaveSavedProcessRuleCommand}"
Padding="10,4"
HorizontalAlignment="Left"/>
</StackPanel>
</GroupBox>
<Border Grid.Column="0"
Padding="18"
IsHitTestVisible="False"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SavedProcessRules.Count}" Value="0">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_NoSavedRules}"
Foreground="{DynamicResource TextSecondaryBrush}"
TextWrapping="Wrap"
TextAlignment="Center"/>
</Border>
</Grid>
</Grid>
</TabItem>
<!-- Automation Monitoring Tab -->
<TabItem Header="{DynamicResource ProcessPowerPlanAssociationView_AutomationMonitoring}">
<ScrollViewer Margin="10">
<StackPanel>
<!-- Service Control -->
<GroupBox Header="{DynamicResource ProcessPowerPlanAssociationView_AutomationService}" Margin="0,0,0,15">
<StackPanel>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_Subtitle}"
Foreground="{DynamicResource TextSecondaryBrush}"
TextWrapping="Wrap"
Margin="0,0,0,10"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_Status}" VerticalAlignment="Center"/>
<TextBlock Text="{Binding ServiceStatus}"
Foreground="{Binding IsServiceRunning, Converter={StaticResource BoolToColorConverter}}"
FontWeight="SemiBold" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_StartAutomation}"
Command="{Binding StartMonitoringCommand}"
IsEnabled="{Binding IsServiceRunning, Converter={StaticResource InverseBoolConverter}}"
Padding="15,8" Margin="0,0,10,0"/>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_StopAutomation}"
Command="{Binding StopMonitoringCommand}"
IsEnabled="{Binding IsServiceRunning}"
Padding="15,8"/>
</StackPanel>
</StackPanel>
</GroupBox>
<!-- Default Power Plan -->
<GroupBox Header="{DynamicResource ProcessPowerPlanAssociationView_DefaultPowerPlan}" Margin="0,0,0,15">
<StackPanel>
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_DefaultPowerPlanHelp}"
Foreground="{DynamicResource TextSecondaryBrush}" Margin="0,0,0,10"/>
<ComboBox ItemsSource="{Binding AvailablePowerPlans}"
SelectedItem="{Binding DefaultPowerPlan}"
DisplayMemberPath="Name"
Padding="5" Margin="0,0,0,10"/>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_SetDefault}"
Command="{Binding SetDefaultPowerPlanCommand}"
Padding="10,5" HorizontalAlignment="Left"/>
</StackPanel>
</GroupBox>
<!-- Automation Monitoring Settings -->
<GroupBox Header="{DynamicResource ProcessPowerPlanAssociationView_SettingsTitle}" Margin="0,0,0,15">
<StackPanel>
<CheckBox Content="{DynamicResource ProcessPowerPlanAssociationView_PreventDuplicates}"
IsChecked="{Binding PreventDuplicatePowerPlanChanges}"
Margin="0,0,0,10"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="{DynamicResource ProcessPowerPlanAssociationView_ChangeDelay}"
VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBox Text="{Binding PowerPlanChangeDelayMs}"
Width="80" Padding="5"/>
</StackPanel>
<Button Content="{DynamicResource ProcessPowerPlanAssociationView_SaveConfig}"
Command="{Binding SaveConfigurationCommand}"
Padding="15,8" HorizontalAlignment="Left"/>
</StackPanel>
</GroupBox>
</StackPanel>
</ScrollViewer>
</TabItem>
</TabControl>
<Border Grid.Row="1"
VerticalAlignment="Bottom"
Margin="10"
Padding="10,7"
CornerRadius="{StaticResource StandardCardCornerRadius}"
BorderThickness="1"
Opacity="{Binding StatusOpacity}"
Visibility="{Binding StatusMessage, Converter={x:Static converters:StringToVisibilityConverter.Instance}}">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="{DynamicResource SuccessBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource SuccessBorderBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding HasError}" Value="True">
<Setter Property="Background" Value="{DynamicResource ErrorBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ErrorBorderBrush}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<TextBlock Text="{Binding StatusMessage}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource SuccessTextBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding HasError}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource ErrorTextBrush}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
</Grid>
</UserControl>