✅ WPF MouseOver expansion of item isn't working

I have a window with a bar that needs to hide down to a separator until the user mouses over it or checks a checkbox (which pins the bar to "open"). However, WPF seems to be claiming if the mouse is over the margin for the separator, it's not over the bar. The code is below.
                <Grid
                    x:Name="gridExtended"
                    DockPanel.Dock="Bottom"
                    IsMouseDirectlyOverChanged="OnExtendedToolBarMouseDirectlyOverChanged">
                    <Grid.RowDefinitions>
                        <RowDefinition
                            Height="10" />
                        <RowDefinition
                            Height="{Binding ExtendedToolBarRowTwoHeight, ElementName=window, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True}" />
                    </Grid.RowDefinitions>
                    <Separator
                        VerticalContentAlignment="Center"
                        HorizontalContentAlignment="Stretch"
                        Grid.ColumnSpan="25"
                        Height="1" />

        public System.Windows.GridLength ExtendedToolBarRowTwoHeight
        {
            get
            {
                if(gridExtended == null || chkExtendedToolBarShow == null)
                    System.Diagnostics.Debug.WriteLine("Nulls");
                else
                    System.Diagnostics.Debug.WriteLine($"Extended: {gridExtended.IsMouseDirectlyOver
                        }\tCheckbox: {chkExtendedToolBarShow.IsChecked}");
                return gridExtended != null && chkExtendedToolBarShow != null && (gridExtended.IsMouseDirectlyOver
                    || chkExtendedToolBarShow.IsChecked == true) ? System.Windows.GridLength.Auto : new
                    (0);
            }
        }

What's going on? It should work so that the bar stays open if the mouse is anywhere over the bar, not just the separator.
Was this page helpful?