Is it possible to disable a ScrollViewer from inside the ScrollViewer?
From a UserControl
, I would like to disable a ScrollViewer
which is defined one level higher. My scenario looks something like this:
<!-- ... -->
<ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled">
<custom:MyUserControl ... />
</ScrollViewer>
Now, I would like to disable the ScrollViewer
from within MyUserControl
. Is this possible?
开发者_运维百科Background:
I have defined a customTabControl
style where I added a ScrollViewer
for each item's content automatically. However, in one case, I do not want to use that ScrollViewer
, but rather make the content size to the available space, whereas in all other cases I do want to use the ScrollViewer. Any ideas? Of course, I could add a ScrollViewer to every tab item manually, except for the one item, but that is not what I want.In code you should be able to do it like this:
try
{
((ScrollViewer)Parent).IsEnabled = false;
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
I've also done it before using triggers in XAML if you need to do it that way let me know and I can post code
精彩评论