Implement ScrollContainerProperty to allow plugins to disable the default scrollviewer wrapper on their controls
This commit is contained in:
@@ -272,6 +272,7 @@
|
||||
<Compile Include="Views\Entities\CharacterView.xaml.cs">
|
||||
<DependentUpon>CharacterView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Extensions.cs" />
|
||||
<Compile Include="Views\ModListControl.xaml.cs">
|
||||
<DependentUpon>ModListControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
24
Torch.Server/Views/Extensions.cs
Normal file
24
Torch.Server/Views/Extensions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Torch.Server.Views
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static readonly DependencyProperty ScrollContainerProperty = DependencyProperty.RegisterAttached("ScrollContainer", typeof(bool), typeof(Extensions), new PropertyMetadata(true));
|
||||
|
||||
public static bool GetScrollContainer(this UIElement ui)
|
||||
{
|
||||
return (bool)ui.GetValue(ScrollContainerProperty);
|
||||
}
|
||||
|
||||
public static void SetScrollContainer(this UIElement ui, bool value)
|
||||
{
|
||||
ui.SetValue(ScrollContainerProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -41,7 +41,9 @@ namespace Torch.Server.Views
|
||||
{
|
||||
if (propertyChangedEventArgs.PropertyName == nameof(PluginManagerViewModel.SelectedPlugin))
|
||||
{
|
||||
if (((PluginManagerViewModel)DataContext).SelectedPlugin.Control is PropertyGrid)
|
||||
var plugin = ((PluginManagerViewModel)DataContext).SelectedPlugin;
|
||||
|
||||
if (plugin.Control is PropertyGrid || !plugin.Control.GetScrollContainer())
|
||||
PScroll.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
|
||||
else
|
||||
PScroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
|
||||
|
Reference in New Issue
Block a user