Fixed obscure FilePicker bug

The exit animations on errors were not firing if the datacontext was what changed.  Adding a middleman property fixed the issue.  Probably a bit hacky
This commit is contained in:
Justin Swanson 2019-12-15 00:20:28 -06:00
parent 705914bd77
commit e388c018dc
7 changed files with 33 additions and 20 deletions

View File

@ -27,20 +27,20 @@
Margin="5,1,-2,1"
VerticalContentAlignment="Center"
Background="{StaticResource DarkBackgroundBrush}"
Text="{Binding TargetPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding ShowTextBoxInput}" />
Text="{Binding PickerVM.TargetPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
Visibility="{Binding PickerVM.ShowTextBoxInput, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
<Grid Grid.Column="1" HorizontalAlignment="Right">
<Border
Margin="3,1,0,1"
HorizontalAlignment="Right"
Background="{StaticResource WarningBrush}"
CornerRadius="3"
ToolTip="{Binding ErrorTooltip}">
ToolTip="{Binding PickerVM.ErrorTooltip, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Width" Value="25" />
<Style.Triggers>
<DataTrigger Binding="{Binding InError}" Value="True">
<DataTrigger Binding="{Binding PickerVM.InError, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
@ -79,7 +79,7 @@
HorizontalAlignment="Left"
Background="{StaticResource TextBoxBackground}"
CornerRadius="3">
<Button Command="{Binding SetTargetPathCommand}" ToolTip="Set target path">
<Button Command="{Binding PickerVM.SetTargetPathCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" ToolTip="Set target path">
<icon:PackIconMaterial
Width="16"
Height="12"

View File

@ -1,4 +1,7 @@
using System.Windows.Controls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Wabbajack.Lib;
namespace Wabbajack
{
@ -7,6 +10,16 @@ namespace Wabbajack
/// </summary>
public partial class FilePicker : UserControl
{
// This exists, as utilizing the datacontext directly seemed to bug out the exit animations
// "Bouncing" off this property seems to fix it, though. Could perhaps be done other ways.
public FilePickerVM PickerVM
{
get => (FilePickerVM)GetValue(PickerVMProperty);
set => SetValue(PickerVMProperty, value);
}
public static readonly DependencyProperty PickerVMProperty = DependencyProperty.Register(nameof(PickerVM), typeof(FilePickerVM), typeof(FilePicker),
new FrameworkPropertyMetadata(default(FilePickerVM)));
public FilePicker()
{
InitializeComponent();

View File

@ -143,7 +143,7 @@
TextWrapping="Wrap" />
<TextBlock Margin="{StaticResource TitleMargin}" Text="Image" />
<local:FilePicker
DataContext="{Binding ImagePath}"
PickerVM="{Binding ImagePath}"
Style="{StaticResource PickerStyle}"
ToolTip="Path to an image to display for the modlist." />
<TextBlock Margin="{StaticResource TitleMargin}" Text="Website" />
@ -153,7 +153,7 @@
Text="Readme Path"
ToolTip="Path to a readme file." />
<local:FilePicker
DataContext="{Binding ReadMeText}"
PickerVM="{Binding ReadMeText}"
Style="{StaticResource PickerStyle}"
ToolTip="Path to a readme file." />
</StackPanel>

View File

@ -34,7 +34,7 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding ModListLocation}"
PickerVM="{Binding ModListLocation}"
FontSize="14"
ToolTip="The MO2 modlist.txt file you want to use as your source" />
<TextBlock
@ -51,7 +51,7 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding DownloadLocation}"
PickerVM="{Binding DownloadLocation}"
FontSize="14"
ToolTip="The folder where MO2 downloads your mods." />
<TextBlock
@ -68,7 +68,7 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding Parent.OutputLocation}"
PickerVM="{Binding Parent.OutputLocation}"
FontSize="14"
ToolTip="The folder to place the resulting modlist.wabbajack file" />
</Grid>

View File

@ -63,7 +63,7 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding GameLocation}"
PickerVM="{Binding GameLocation}"
FontSize="14"
ToolTip="The install folder for the game" />
<Grid
@ -109,7 +109,7 @@
Grid.Column="6"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding DownloadsLocation}"
PickerVM="{Binding DownloadsLocation}"
FontSize="14"
ToolTip="The folder to download your mods" />
<TextBlock
@ -125,7 +125,7 @@
Grid.Column="6"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding StagingLocation}"
PickerVM="{Binding StagingLocation}"
FontSize="14" />
<TextBlock
Grid.Row="2"
@ -141,7 +141,7 @@
Grid.Column="6"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding Parent.OutputLocation}"
PickerVM="{Binding Parent.OutputLocation}"
FontSize="14"
ToolTip="The folder to place the resulting modlist.wabbajack file" />
</Grid>

View File

@ -314,7 +314,7 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding ModListLocation}"
PickerVM="{Binding ModListLocation}"
FontSize="14" />
<ContentPresenter
Grid.Row="3"

View File

@ -33,8 +33,8 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding Location}"
FontSize="14" />
FontSize="14"
PickerVM="{Binding Location}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
@ -48,8 +48,8 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding DownloadLocation}"
FontSize="14" />
FontSize="14"
PickerVM="{Binding DownloadLocation}" />
<CheckBox
Grid.Row="2"
Grid.Column="2"