Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4929 from Vogel612/fix/language-change-exception
Fix language change exception
- Loading branch information
Showing
13 changed files
with
231 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
58 changes: 58 additions & 0 deletions
58
Rubberduck.Core/UI/Controls/Behavior/ResetValueBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Windows; | ||
using System.Windows.Controls.Primitives; | ||
|
||
namespace Rubberduck.UI.Controls.Behavior | ||
{ | ||
using ButtonBehavior = System.Windows.Interactivity.Behavior<ButtonBase>; | ||
|
||
public class ResetValueBehavior : ButtonBehavior | ||
{ | ||
private ButtonBase _associatedButton; | ||
|
||
protected override void OnAttached() | ||
{ | ||
_associatedButton = AssociatedObject; | ||
|
||
_associatedButton.Click += AssociatedButtonClick; | ||
} | ||
|
||
protected override void OnDetaching() | ||
{ | ||
_associatedButton.Click -= AssociatedButtonClick; | ||
} | ||
|
||
private void AssociatedButtonClick(object sender, RoutedEventArgs e) | ||
{ | ||
Affects = Default; | ||
} | ||
|
||
public object Affects | ||
{ | ||
get => GetValue(AffectsProperty); | ||
set | ||
{ | ||
var oldValue = Affects; | ||
SetValue(AffectsProperty, value); | ||
OnPropertyChanged(new DependencyPropertyChangedEventArgs(AffectsProperty, oldValue, value)); | ||
} | ||
} | ||
|
||
public object Default | ||
{ | ||
get => GetValue(DefaultProperty); | ||
set | ||
{ | ||
var oldValue = Default; | ||
SetValue(DefaultProperty, value); | ||
OnPropertyChanged(new DependencyPropertyChangedEventArgs(DefaultProperty, oldValue, value)); | ||
} | ||
} | ||
|
||
// Using a DependencyProperty as the backing store for Affects. | ||
// This enables animation, styling, binding, etc... | ||
public static readonly DependencyProperty AffectsProperty = | ||
DependencyProperty.Register("Affects", typeof(object), typeof(ResetValueBehavior), new UIPropertyMetadata()); | ||
public static readonly DependencyProperty DefaultProperty = | ||
DependencyProperty.Register("Default", typeof(object), typeof(ResetValueBehavior), new UIPropertyMetadata(defaultValue: null)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<UserControl x:Class="Rubberduck.UI.Controls.SearchBox" | ||
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:i="http://schemas.microsoft.com/expression/2010/interactivity" | ||
xmlns:local="clr-namespace:Rubberduck.UI.Controls;assembly=" | ||
xmlns:ib="clr-namespace:Rubberduck.UI.Controls.Behavior;assembly=" | ||
xmlns:converters="clr-namespace:Rubberduck.UI.Converters;assembly=" | ||
mc:Ignorable="d" | ||
MinWidth="50" MinHeight="20" | ||
Height="20" | ||
Name="Root" | ||
d:DesignHeight="20" d:DesignWidth="400" | ||
d:DataContext="{d:DesignInstance local:SearchBox, IsDesignTimeCreatable=True}"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="20" /> | ||
</Grid.ColumnDefinitions> | ||
<TextBox Text="{Binding Path=Text, ElementName=Root, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | ||
x:Name="ValueContainer" | ||
Background="Transparent" | ||
Panel.ZIndex="2" | ||
VerticalContentAlignment="Center" | ||
Width="Auto" | ||
Grid.Row="0" Grid.Column="0"/> | ||
<!-- this is the actual hint container, it's BELOW the displaying control --> | ||
<TextBox Text="{Binding Path=Hint, ElementName=Root, Mode=OneWay}" | ||
Background="{Binding Path=Background, ElementName=Root}" | ||
Width="{Binding Path=ActualWidth, ElementName=ValueContainer}" | ||
Height="{Binding Path=ActualHeight, ElementName=ValueContainer}" | ||
Panel.ZIndex="1" | ||
VerticalContentAlignment="Center" | ||
Grid.Row="0" Grid.Column="0"> | ||
<TextBox.Style> | ||
<Style TargetType="{x:Type TextBox}"> | ||
<!-- Setter needs to be within this type to be overwritable with a trigger --> | ||
<Setter Property="Foreground" Value="Transparent" /> | ||
<Style.Triggers> | ||
<DataTrigger Binding="{Binding Path=Text, Source={x:Reference ValueContainer}}" Value=""> | ||
<Setter Property="Foreground" Value="{x:Static SystemColors.GrayTextBrush}"/> | ||
</DataTrigger> | ||
</Style.Triggers> | ||
</Style> | ||
</TextBox.Style> | ||
</TextBox> | ||
<Button Name="SearchButton" Grid.Column="1" Command="{Binding ClearSearchCommand}" | ||
BorderBrush="{x:Static SystemColors.ControlLightBrush}" | ||
Background="Transparent" | ||
Width="20" Height="20" Padding="0" Margin="0,1" | ||
xmlns:sys="clr-namespace:System;assembly=mscorlib"> | ||
<Button.Resources> | ||
<converters:SearchImageSourceConverter x:Key="SearchToIcon" /> | ||
</Button.Resources> | ||
<Image VerticalAlignment="Center" HorizontalAlignment="Center" | ||
Width="16" Height="16" | ||
Source="{Binding Text, ElementName=ValueContainer, | ||
Converter={StaticResource SearchToIcon}, | ||
UpdateSourceTrigger=PropertyChanged}" /> | ||
<i:Interaction.Behaviors> | ||
<local:FocusElementAfterClickBehavior FocusElement="{x:Reference ValueContainer}"/> | ||
<ib:ResetValueBehavior Affects="{Binding Path=Text, ElementName=ValueContainer, Mode=OneWayToSource}" | ||
Default="{x:Static sys:String.Empty}"/> | ||
</i:Interaction.Behaviors> | ||
</Button> | ||
</Grid> | ||
</UserControl> |
Oops, something went wrong.