fix: fix reapplying template initialization issue.
This commit is contained in:
@@ -4,6 +4,9 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:u="https://irihi.tech/ursa"
|
xmlns:u="https://irihi.tech/ursa"
|
||||||
mc:Ignorable="d" d:DesignWidth="800"
|
mc:Ignorable="d" d:DesignWidth="800"
|
||||||
|
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||||
|
x:DataType="vm:RangeSliderDemoViewModel"
|
||||||
|
x:CompileBindings="True"
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
x:Class="Ursa.Demo.Pages.RangeSliderDemo">
|
x:Class="Ursa.Demo.Pages.RangeSliderDemo">
|
||||||
<UserControl.Styles>
|
<UserControl.Styles>
|
||||||
@@ -12,11 +15,12 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</UserControl.Styles>
|
</UserControl.Styles>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<u:RangeSlider Name="range" TickFrequency="5" IsSnapToTick="True" TickPlacement="TopLeft"/>
|
<u:RangeSlider TickFrequency="5" IsSnapToTick="True" TickPlacement="TopLeft"/>
|
||||||
<u:NumericDoubleUpDown InnerLeftContent="Minimum" Value="{Binding #range.Minimum, Mode=TwoWay}" />
|
<u:NumericDoubleUpDown InnerLeftContent="Minimum" Value="{Binding #range.Minimum, Mode=TwoWay}" />
|
||||||
<u:NumericDoubleUpDown InnerLeftContent="Maximum" Value="{Binding #range.Maximum, Mode=TwoWay}" />
|
<u:NumericDoubleUpDown InnerLeftContent="Maximum" Value="{Binding #range.Maximum, Mode=TwoWay}" />
|
||||||
<u:NumericDoubleUpDown InnerLeftContent="LowerValue" Value="{Binding #range.LowerValue, Mode=TwoWay}" />
|
<u:NumericDoubleUpDown InnerLeftContent="LowerValue" Value="{Binding #range.LowerValue, Mode=TwoWay}" />
|
||||||
<u:NumericDoubleUpDown InnerLeftContent="UpperValue" Value="{Binding #range.UpperValue, Mode=TwoWay}" />
|
<u:NumericDoubleUpDown InnerLeftContent="UpperValue" Value="{Binding #range.UpperValue, Mode=TwoWay}" />
|
||||||
<u:RangeSlider TickFrequency="5" Orientation="Vertical" Height="300"></u:RangeSlider>
|
<ComboBox ItemsSource="{Binding Orientations}" SelectedItem="{Binding Orientation}"></ComboBox>
|
||||||
|
<u:RangeSlider Name="range" TickFrequency="5" Orientation="{Binding Orientation}" Height="300"></u:RangeSlider>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using Avalonia.Layout;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
namespace Ursa.Demo.ViewModels;
|
namespace Ursa.Demo.ViewModels;
|
||||||
|
|
||||||
public class RangeSliderDemoViewModel: ObservableObject
|
public partial class RangeSliderDemoViewModel: ObservableObject
|
||||||
{
|
{
|
||||||
|
public ObservableCollection<Orientation> Orientations { get; set; } = new ObservableCollection<Orientation>()
|
||||||
|
{
|
||||||
|
Orientation.Horizontal,
|
||||||
|
Orientation.Vertical
|
||||||
|
};
|
||||||
|
|
||||||
|
[ObservableProperty] private Orientation _orientation;
|
||||||
}
|
}
|
||||||
@@ -54,11 +54,11 @@
|
|||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Orientation="{Binding Orientation, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
Orientation="{Binding Orientation, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
LowerValue="{Binding LowerValue, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
LowerValue="{Binding LowerValue, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
Maximum="{Binding Maximum, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
Maximum="{Binding Maximum, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
Minimum="{Binding Minimum, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
Minimum="{Binding Minimum, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
UpperValue="{Binding UpperValue, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
|
UpperValue="{Binding UpperValue, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
|
||||||
<u:RangeTrack.LowerSection>
|
<u:RangeTrack.LowerSection>
|
||||||
<Border
|
<Border
|
||||||
Name="PART_LowerSection"
|
Name="PART_LowerSection"
|
||||||
@@ -145,11 +145,11 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Orientation="{Binding Orientation, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
Orientation="{Binding Orientation, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
LowerValue="{Binding LowerValue, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
LowerValue="{Binding LowerValue, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
Maximum="{Binding Maximum, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
Maximum="{Binding Maximum, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
Minimum="{Binding Minimum, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
Minimum="{Binding Minimum, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
UpperValue="{Binding UpperValue, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
|
UpperValue="{Binding UpperValue, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
|
||||||
<u:RangeTrack.LowerSection>
|
<u:RangeTrack.LowerSection>
|
||||||
<Border
|
<Border
|
||||||
Name="PART_LowerSection"
|
Name="PART_LowerSection"
|
||||||
|
|||||||
Reference in New Issue
Block a user