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” and “HorizontalScrollBarVisibility” 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 not find the solution
Contact Support
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:
<div class="scrollable-container" onmouseover="showScrollbar()" onmouseleave="hideScrollbar()"> <div class="content"> <!-- Your content here --> </div> </div>
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:
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 theoverflow-y
property to "scroll," displaying the scrollbar. Conversely, when the mouse leaves the container, thehideScrollbar()
function is called, setting theoverflow-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