Merge pull request #83 from irihitech/issue/82
Fix: fix pointer press handling.
This commit is contained in:
@@ -15,6 +15,11 @@
|
||||
<Button Content="Dialog" Command="{Binding DialogCommand}"></Button>
|
||||
<Button Content="OK" Command="{Binding OKCommand}"></Button>
|
||||
<Button Content="Cancel" Command="{Binding CancelCommand}"></Button>
|
||||
<ComboBox>
|
||||
<ComboBoxItem>A</ComboBoxItem>
|
||||
<ComboBoxItem>B</ComboBoxItem>
|
||||
<ComboBoxItem>C</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -9,5 +9,10 @@
|
||||
x:Class="Ursa.Demo.Dialogs.PlainDialog">
|
||||
<StackPanel>
|
||||
<Calendar SelectedDate="{Binding Date}" ></Calendar>
|
||||
<ComboBox>
|
||||
<ComboBoxItem>A</ComboBoxItem>
|
||||
<ComboBoxItem>B</ComboBoxItem>
|
||||
<ComboBoxItem>C</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -387,13 +387,18 @@
|
||||
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
||||
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
|
||||
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
||||
<ChromeOverlayLayer />
|
||||
<VisualLayerManager>
|
||||
<Grid RowDefinitions="Auto, *">
|
||||
<ContentPresenter
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Content="{TemplateBinding Content}" />
|
||||
<Grid Grid.Row="0" ColumnDefinitions="*, Auto">
|
||||
<Panel
|
||||
Name="{x:Static u:DialogWindow.PART_TitleArea}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Background="Transparent" />
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Margin="24,24,0,0"
|
||||
@@ -409,6 +414,7 @@
|
||||
Theme="{DynamicResource CloseButton}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</VisualLayerManager>
|
||||
</Panel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
@@ -444,7 +450,7 @@
|
||||
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
||||
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
|
||||
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
||||
<ChromeOverlayLayer />
|
||||
<VisualLayerManager>
|
||||
<Grid RowDefinitions="Auto, *, Auto">
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
@@ -453,7 +459,7 @@
|
||||
Content="{TemplateBinding Content}" />
|
||||
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
|
||||
<Panel
|
||||
Name="{x:Static u:DialogControl.PART_TitleArea}"
|
||||
Name="{x:Static u:DialogWindow.PART_TitleArea}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Background="Transparent" />
|
||||
@@ -513,6 +519,7 @@
|
||||
Theme="{DynamicResource SolidButton}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</VisualLayerManager>
|
||||
</Panel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
@@ -9,13 +9,15 @@ using Ursa.Common;
|
||||
namespace Ursa.Controls;
|
||||
|
||||
[TemplatePart(PART_CloseButton, typeof(Button))]
|
||||
[TemplatePart(PART_TitleArea, typeof(Panel))]
|
||||
public class DialogWindow: Window
|
||||
{
|
||||
public const string PART_CloseButton = "PART_CloseButton";
|
||||
|
||||
public const string PART_TitleArea = "PART_TitleArea";
|
||||
protected override Type StyleKeyOverride { get; } = typeof(DialogWindow);
|
||||
|
||||
private Button? _closeButton;
|
||||
private Panel? _titleArea;
|
||||
|
||||
static DialogWindow()
|
||||
{
|
||||
@@ -39,7 +41,10 @@ public class DialogWindow: Window
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
EventHelper.UnregisterClickEvent(OnDefaultClose, _closeButton);
|
||||
_titleArea?.RemoveHandler(PointerPressedEvent, OnTitlePointerPressed);
|
||||
_closeButton = e.NameScope.Find<Button>(PART_CloseButton);
|
||||
_titleArea = e.NameScope.Find<Panel>(PART_TitleArea);
|
||||
_titleArea?.AddHandler(PointerPressedEvent, OnTitlePointerPressed, RoutingStrategies.Bubble);
|
||||
EventHelper.RegisterClickEvent(OnDefaultClose, _closeButton);
|
||||
}
|
||||
|
||||
@@ -60,7 +65,7 @@ public class DialogWindow: Window
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
private void OnTitlePointerPressed(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
this.BeginMoveDrag(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user