ScrollViewer scrollbars not hiding/showing
Posted: 05 Jun 2015, 00:44
I have an Image inside a ScrollViewer. The XAML has both the horizontal and vertical scrollbar visibility set to Auto. The initial Image is initially sized to the exact dimensions of the ScrollViewer. The initial view shows the entire image without any scrollbars. When I enlarge the Image, scrollbars appear, as expected. However, when I reset the size back to the initial dimensions, the scrollbars do not go away.
I tried to force the display of the scrollbars, but the methods for changing the scrollbar visibility do not seem to work. Here is my code:
I've also tried ScrollBarVisibility.Hidden, but that doesn't work, either.
I'm using v1.2.3 in Unity 5, running on Windows 8.1.
I tried to force the display of the scrollbars, but the methods for changing the scrollbar visibility do not seem to work. Here is my code:
Code: Select all
void buttonDebugZoom_Click(object sender, RoutedEventArgs e)
{
Debug.Log("+buttonDebugZoom_Click");
fDebugZoom = !fDebugZoom;
if (fDebugZoom)
{
Debug.Log(" zoomed in");
imgDebug.Width = cachedImageData.width/2;
imgDebug.Height = cachedImageData.height/2;
ScrollViewer.SetHorizontalScrollBarVisibility(svDebug, ScrollBarVisibility.Visible);
ScrollViewer.SetVerticalScrollBarVisibility(svDebug, ScrollBarVisibility.Visible);
buttonDebugZoom.Content = "Zoom -";
}
else
{
Debug.Log(" zoomed out");
imgDebug.Width = svDebug.ActualWidth;
imgDebug.Height = svDebug.ActualHeight;
ScrollViewer.SetHorizontalScrollBarVisibility(svDebug, ScrollBarVisibility.Disabled);
ScrollViewer.SetVerticalScrollBarVisibility(svDebug, ScrollBarVisibility.Disabled);
buttonDebugZoom.Content = "Zoom +";
}
}I'm using v1.2.3 in Unity 5, running on Windows 8.1.