Skip to content

PopTip.Instance NullRef #239

@Gamer-XP

Description

@Gamer-XP

Describe the bug

I have an issue with PopTip. I got one in DataTemplate that used used in ComboBox. If I change values to a type that used different DataTemplate - I get an nullRef error for changing Instance. Trying to show just null value will give same result.

It happens in this method:

    private static void OnInstanceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        if (d is not FrameworkElement target) return;
        var element = (AdornerElement) e.NewValue;
        // Element is null here
        element.OnInstanceChanged(target);
    }

This is the call stack:
https://gyazo.com/ad985bd2b4128aa176fe1c8dad39d499

Steps to reproduce the bug

The Template I used. It shows Image from the ViewModel. Doesn't really do anything else.

<DataTemplate DataType="{x:Type resources:SpriteViewModel}">
        <presets:CollectionItemDefault>

            <presets:CollectionItemDefault.IconContent>
                <Image Source="{Binding MainImage}"/>
            </presets:CollectionItemDefault.IconContent>

            <TextBlock Text="{Binding Name}" />

            <hc:Poptip.Instance>
                <hc:Poptip DataContext="{Binding Target.DataContext, RelativeSource={RelativeSource Self}}" IsHitTestVisible="False" PlacementType="Left" HitMode="Hover" Delay="100">
                    <hc:Poptip.Content>
                        <GroupBox Width="300" Height="350">
                            <GroupBox.Header>
                                <TextBlock Text="{Binding Name}"/>
                            </GroupBox.Header>

                            <Image Source="{Binding MainImage}" />

                        </GroupBox>
                    </hc:Poptip.Content>
                </hc:Poptip>
            </hc:Poptip.Instance>

        </presets:CollectionItemDefault>
    </DataTemplate>

Expected behavior

No response

Screenshots

No response

NuGet package version

HandyControl 3.5.1

IDE

Visual Studio 2022

Framework type

.Net 9.0

Windows version

May 2021 Update (19043)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions