fix CheckBox animation throwing NullReferenceException on ObservableCollection changes#1660
fix CheckBox animation throwing NullReferenceException on ObservableCollection changes#1660Muniwedesu wants to merge 1 commit into
Conversation
|
Can you expand on what this fixes? You say #1140, but that one was closed (and thus presumably fixed) last year? Do you have a repro? |
That particular issue was with CardExpander and it was fixed, yes, this one does the same thing with CheckBox, maybe there are other controls like that. To reproduce just click on Remove/Clear button when checkbox is checked or was interacted with |
|
This is not complete, I don't have write access to the PR, but the Tag needs to be replaced as well: <controls:SymbolIcon.Clip>
<MultiBinding Converter="{StaticResource ClipConverter}">
<MultiBinding.Bindings>
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
<Binding Path="(animations:AnimationProperties.AnimationTagValue)" RelativeSource="{RelativeSource Self}" />
</MultiBinding.Bindings>
</MultiBinding>
</controls:SymbolIcon.Clip>
<animations:AnimationProperties.AnimationTagValue>
<system:Double>1</system:Double>
</animations:AnimationProperties.AnimationTagValue> |
|
@Nuklon would you like to make a proper PR and I'll just close/delete mine then? (don't know how this works on github) |
|
You should be able to fix the issue yourself with another commit on this branch :) |
|
Somewhat minimal repro: App.xaml: <Application
x:Class="wpfui1512bug.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"/>MainWindow.xaml: <Window
x:Class="wpfui1512bug.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="MainWindow"
Width="800"
Height="450"
AllowsTransparency="True"
Loaded="MainWindow_OnLoaded"
WindowStyle="None"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemesDictionary Theme="Light"/>
<ui:ControlsDictionary/>
<!-- <ResourceDictionary Source="FixedCheckBox.xaml"/> -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid x:Name="Root">
<Grid x:Name="OuterContainer">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ui:TitleBar Title="Hello"/>
<ContentControl x:Name="Host" Grid.Row="1">
<CheckBox x:Name="OldCheckBox" Width="100">Is fancy</CheckBox>
</ContentControl>
</Grid>
</Grid>
</Window>MainWindow.xaml.cs: using System.Windows;
using System.Windows.Controls;
namespace wpfui1512bug;
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
OldCheckBox.IsChecked = true;
// force some of the checkbox animation to play
await Task.Delay(500);
Host.Content = new CheckBox
{
Content = "got here"
};
}
}Merely launching that will crash: Uncomment I can't get it to reproduce when WPF UI is part of the application style, but regardless, there's a bug in the animation here, introduced between 4.0.3 and 4.1, so #1512 would be my guess. |
Use DependencyProperty for getting/setting the Tag property value to avoid it having the default value of 'null'
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: #1140
What is the new behavior?
Other information