Articles in this section
Category / Section

How to show and hide scrollbar on mouse over and mouse leave respectively

1 min read

To show scrollbar on mouse over set VerticalScrollBarVisibility andHorizontalScrollBarVisibility properties to Auto mode when IsMouseOver property is True otherwise set to Hidden.

XAML

    <Grid>
        <Grid.Resources>
                <Style TargetType="syncfusion:EditControl">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
                            <Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="False">
                            <Setter Property="HorizontalScrollBarVisibility" Value="Hidden"/>
                            <Setter Property="VerticalScrollBarVisibility" Value="Hidden"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>         
        </Grid.Resources>
        <syncfusion:EditControl HorizontalContentAlignment="Left" Text="{Binding Text}"  DocumentLanguage="SQL"/>
    </Grid>

 

The following screenshots illustrates the output of the above code example

On mouse over:

On mouse leave:

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (1)
Please  to leave a comment
OT
Only TDM

To show and hide the scrollbar on mouse over and mouse leave respectively, you can utilize CSS and JavaScript. Here's an example of how you can achieve this:

HTML:

html
<div class="scrollable-container" onmouseover="showScrollbar()" onmouseleave="hideScrollbar()"> <div class="content"> <!-- Your content here --> </div> </div>

CSS:

css
.scrollable-container { width: 300px; /* Set the desired width */ height: 200px; /* Set the desired height */ overflow: hidden; } .scrollable-container:hover { overflow-y: scroll; } .content { /* Set the desired styles for the content */ }

JavaScript:

javascript
function showScrollbar() { var container = document.querySelector('.scrollable-container'); container.style.overflowY = 'scroll'; } function hideScrollbar() { var container = document.querySelector('.scrollable-container'); container.style.overflowY = 'hidden'; }

In this example, we have a scrollable container with a fixed width and height. When the mouse hovers over the container, the showScrollbar() function is triggered, which sets the overflow-y property to "scroll," displaying the scrollbar. Conversely, when the mouse leaves the container, the hideScrollbar() function is called, setting the overflow-y property to "hidden," hiding the scrollbar.

Please note that you can modify the width, height, and styles according to your specific requirements.


Tech Beast Reviews

Access denied
Access denied