© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
15 replies
Will Pittenger

✅ 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" />
                <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);
            }
        }
        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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

❔ WPF Use of multiple item controls
C#CC# / help
4y ago
✅ bracket pairing isn't working
C#CC# / help
10mo ago
Damage system isn't working
C#CC# / help
2y ago
✅ My bot isn't working
C#CC# / help
3y ago