chore: Attempt to Change Scroll Value
Issues: - Not cropping to lowest Zindex content (Grid Row 0) - ScrollBars won't work propperly
This commit is contained in:
Родитель
e0894af312
Коммит
de5f0e0290
|
@ -2,7 +2,6 @@ using Microsoft.UI.Input;
|
|||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Windows.Foundation;
|
||||
|
||||
|
@ -189,9 +188,27 @@ public partial class ZoomContentControl : ContentControl
|
|||
|
||||
RegisterPropertyChangedCallback(ZoomLevelProperty, (s, e) => { UpdateScrollLimits(); });
|
||||
|
||||
RegisterPropertyChangedCallback(HorizontalOffsetProperty, UpdateVerticalScrollBarValue);
|
||||
RegisterPropertyChangedCallback(VerticalOffsetProperty, UpdateHorizontalScrollBarValue);
|
||||
|
||||
RegisterPropertyChangedCallback(IsActiveProperty, IsActiveChanged);
|
||||
}
|
||||
|
||||
private void UpdateVerticalScrollBarValue(DependencyObject sender, DependencyProperty dp)
|
||||
{
|
||||
if (_scrollV is not null)
|
||||
{
|
||||
_scrollV.Value = VerticalOffset;
|
||||
}
|
||||
}
|
||||
private void UpdateHorizontalScrollBarValue(DependencyObject sender, DependencyProperty dp)
|
||||
{
|
||||
if (_scrollH is not null)
|
||||
{
|
||||
_scrollH.Value = HorizontalOffset;
|
||||
}
|
||||
}
|
||||
|
||||
private void IsActiveChanged(DependencyObject sender, DependencyProperty dp)
|
||||
{
|
||||
if (ResetWhenNotActive && !IsActive)
|
||||
|
@ -273,22 +290,22 @@ public partial class ZoomContentControl : ContentControl
|
|||
HorizontalOffset = e.NewValue;
|
||||
}
|
||||
|
||||
private void ApplyBindings()
|
||||
{
|
||||
if (_scrollV is not null)
|
||||
{
|
||||
var sVBinding = new Binding { Path = new PropertyPath("VerticalOffset"), Mode = BindingMode.TwoWay };
|
||||
sVBinding.Source = this;
|
||||
_scrollV.SetBinding(ScrollBar.ValueProperty, sVBinding);
|
||||
}
|
||||
//private void ApplyBindings()
|
||||
//{
|
||||
// if (_scrollV is not null)
|
||||
// {
|
||||
// var sVBinding = new Binding { Path = new PropertyPath("VerticalOffset"), Mode = BindingMode.TwoWay };
|
||||
// sVBinding.Source = this;
|
||||
// _scrollV.SetBinding(ScrollBar.ValueProperty, sVBinding);
|
||||
// }
|
||||
|
||||
if (_scrollH is not null)
|
||||
{
|
||||
var sHBinding = new Binding { Path = new PropertyPath("HorizontalOffset"), Mode = BindingMode.TwoWay };
|
||||
sHBinding.Source = this;
|
||||
_scrollH.SetBinding(ScrollBar.ValueProperty, sHBinding);
|
||||
}
|
||||
}
|
||||
// if (_scrollH is not null)
|
||||
// {
|
||||
// var sHBinding = new Binding { Path = new PropertyPath("HorizontalOffset"), Mode = BindingMode.TwoWay };
|
||||
// sHBinding.Source = this;
|
||||
// _scrollH.SetBinding(ScrollBar.ValueProperty, sHBinding);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
private uint _capturedPointerId;
|
||||
|
|
|
@ -3,80 +3,73 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ctl="using:InteractionControls">
|
||||
|
||||
<Style x:Key="DefaultZoomContentControlStyle" TargetType="ctl:ZoomContentControl">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ctl:ZoomContentControl">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border
|
||||
<Style x:Key="DefaultZoomContentControlStyle" TargetType="ctl:ZoomContentControl">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ctl:ZoomContentControl">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Background="{TemplateBinding Background}">
|
||||
<ContentPresenter
|
||||
<ContentPresenter
|
||||
x:Name="PART_Presenter"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}">
|
||||
<ContentPresenter.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform CenterX="{TemplateBinding HorizontalZoomCenter}" CenterY="{TemplateBinding VerticalZoomCenter}" ScaleX="{TemplateBinding ZoomLevel}" ScaleY="{TemplateBinding ZoomLevel}" />
|
||||
<TranslateTransform X="{TemplateBinding HorizontalOffset}" Y="{TemplateBinding VerticalOffset}" />
|
||||
</TransformGroup>
|
||||
</ContentPresenter.RenderTransform>
|
||||
</ContentPresenter>
|
||||
</Border>
|
||||
<!-- Vertical ScrollBar -->
|
||||
<ScrollBar
|
||||
<ContentPresenter.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform CenterX="{TemplateBinding HorizontalZoomCenter}" CenterY="{TemplateBinding VerticalZoomCenter}" ScaleX="{TemplateBinding ZoomLevel}" ScaleY="{TemplateBinding ZoomLevel}" />
|
||||
<TranslateTransform X="{TemplateBinding HorizontalOffset}" Y="{TemplateBinding VerticalOffset}" />
|
||||
</TransformGroup>
|
||||
</ContentPresenter.RenderTransform>
|
||||
</ContentPresenter>
|
||||
</Border>
|
||||
<!-- Vertical ScrollBar -->
|
||||
<ScrollBar
|
||||
x:Name="PART_scrollV"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Stretch"
|
||||
LargeChange="100"
|
||||
IndicatorMode="MouseIndicator"
|
||||
LargeChange="10"
|
||||
Maximum="{TemplateBinding VerticalMaxScroll}"
|
||||
Minimum="{TemplateBinding VerticalMinScroll}"
|
||||
Orientation="Vertical"
|
||||
SmallChange="10"
|
||||
ViewportSize="{TemplateBinding ViewPortHeight}"
|
||||
Value="{TemplateBinding VerticalOffset}" />
|
||||
<!-- Horizontal ScrollBar -->
|
||||
<TextBlock
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="16"
|
||||
Foreground="Red"
|
||||
Text="{Binding Value, ElementName=PART_scrollH}" />
|
||||
<ScrollBar
|
||||
SmallChange="1"
|
||||
ViewportSize="{TemplateBinding ViewPortHeight}" />
|
||||
<!-- Horizontal ScrollBar -->
|
||||
<ScrollBar
|
||||
x:Name="PART_scrollH"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Bottom"
|
||||
IndicatorMode="MouseIndicator"
|
||||
LargeChange="100"
|
||||
LargeChange="10"
|
||||
Maximum="{TemplateBinding HorizontalMaxScroll}"
|
||||
Minimum="{TemplateBinding HorizontalMinScroll}"
|
||||
Orientation="Horizontal"
|
||||
SmallChange="10"
|
||||
ViewportSize="{TemplateBinding ViewPortWidth}"
|
||||
Value="{TemplateBinding HorizontalOffset}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
SmallChange="1"
|
||||
ViewportSize="{TemplateBinding ViewPortWidth}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ctl:ZoomContentControl" BasedOn="{StaticResource DefaultZoomContentControlStyle}" />
|
||||
<Style BasedOn="{StaticResource DefaultZoomContentControlStyle}" TargetType="ctl:ZoomContentControl" />
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
|
|
|
@ -40,10 +40,6 @@
|
|||
IsActive="{Binding IsOn, ElementName=swEnable}">
|
||||
<StackPanel>
|
||||
<Image Source="https://uno-website-assets.s3.amazonaws.com/wp-content/uploads/2023/05/12134055/SeingBelieving_2apps-1-1-1024x358.png" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
AutomationProperties.AutomationId="HelloTextBlock"
|
||||
Text="Hello Uno Platform" />
|
||||
</StackPanel>
|
||||
</controls:ZoomContentControl>
|
||||
</Grid>
|
||||
|
|
Загрузка…
Ссылка в новой задаче