Fix: fix pointer press handling.
This commit is contained in:
@@ -15,6 +15,11 @@
|
|||||||
<Button Content="Dialog" Command="{Binding DialogCommand}"></Button>
|
<Button Content="Dialog" Command="{Binding DialogCommand}"></Button>
|
||||||
<Button Content="OK" Command="{Binding OKCommand}"></Button>
|
<Button Content="OK" Command="{Binding OKCommand}"></Button>
|
||||||
<Button Content="Cancel" Command="{Binding CancelCommand}"></Button>
|
<Button Content="Cancel" Command="{Binding CancelCommand}"></Button>
|
||||||
|
<ComboBox>
|
||||||
|
<ComboBoxItem>A</ComboBoxItem>
|
||||||
|
<ComboBoxItem>B</ComboBoxItem>
|
||||||
|
<ComboBoxItem>C</ComboBoxItem>
|
||||||
|
</ComboBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -9,5 +9,10 @@
|
|||||||
x:Class="Ursa.Demo.Dialogs.PlainDialog">
|
x:Class="Ursa.Demo.Dialogs.PlainDialog">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Calendar SelectedDate="{Binding Date}" ></Calendar>
|
<Calendar SelectedDate="{Binding Date}" ></Calendar>
|
||||||
|
<ComboBox>
|
||||||
|
<ComboBoxItem>A</ComboBoxItem>
|
||||||
|
<ComboBoxItem>B</ComboBoxItem>
|
||||||
|
<ComboBoxItem>C</ComboBoxItem>
|
||||||
|
</ComboBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -387,28 +387,34 @@
|
|||||||
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
||||||
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
|
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
|
||||||
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
||||||
<ChromeOverlayLayer />
|
<VisualLayerManager>
|
||||||
<Grid RowDefinitions="Auto, *">
|
<Grid RowDefinitions="Auto, *">
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.RowSpan="2"
|
Grid.RowSpan="2"
|
||||||
Content="{TemplateBinding Content}" />
|
Content="{TemplateBinding Content}" />
|
||||||
<Grid Grid.Row="0" ColumnDefinitions="*, Auto">
|
<Grid Grid.Row="0" ColumnDefinitions="*, Auto">
|
||||||
<TextBlock
|
<Panel
|
||||||
Grid.Column="0"
|
Name="{x:Static u:DialogWindow.PART_TitleArea}"
|
||||||
Margin="24,24,0,0"
|
Grid.Column="0"
|
||||||
FontSize="14"
|
Grid.ColumnSpan="2"
|
||||||
FontWeight="Bold"
|
Background="Transparent" />
|
||||||
Text="{TemplateBinding Title}"
|
<TextBlock
|
||||||
TextTrimming="CharacterEllipsis"
|
Grid.Column="0"
|
||||||
TextWrapping="NoWrap" />
|
Margin="24,24,0,0"
|
||||||
<Button
|
FontSize="14"
|
||||||
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
|
FontWeight="Bold"
|
||||||
Grid.Column="1"
|
Text="{TemplateBinding Title}"
|
||||||
Margin="0,24,24,0"
|
TextTrimming="CharacterEllipsis"
|
||||||
Theme="{DynamicResource CloseButton}" />
|
TextWrapping="NoWrap" />
|
||||||
|
<Button
|
||||||
|
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
|
||||||
|
Grid.Column="1"
|
||||||
|
Margin="0,24,24,0"
|
||||||
|
Theme="{DynamicResource CloseButton}" />
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</VisualLayerManager>
|
||||||
</Panel>
|
</Panel>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
@@ -444,75 +450,76 @@
|
|||||||
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
||||||
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
|
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
|
||||||
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
||||||
<ChromeOverlayLayer />
|
<VisualLayerManager>
|
||||||
<Grid RowDefinitions="Auto, *, Auto">
|
<Grid RowDefinitions="Auto, *, Auto">
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
Name="PART_ContentPresenter"
|
Name="PART_ContentPresenter"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Margin="24,8"
|
Margin="24,8"
|
||||||
Content="{TemplateBinding Content}" />
|
Content="{TemplateBinding Content}" />
|
||||||
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
|
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
|
||||||
<Panel
|
<Panel
|
||||||
Name="{x:Static u:DialogControl.PART_TitleArea}"
|
Name="{x:Static u:DialogWindow.PART_TitleArea}"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Grid.ColumnSpan="3"
|
Grid.ColumnSpan="3"
|
||||||
Background="Transparent" />
|
Background="Transparent" />
|
||||||
<PathIcon
|
<PathIcon
|
||||||
Name="PART_Icon"
|
Name="PART_Icon"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Width="16"
|
Width="16"
|
||||||
Height="16"
|
Height="16"
|
||||||
Margin="24,24,8,0"
|
Margin="24,24,8,0"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Name="PART_Title"
|
Name="PART_Title"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="0,24,0,0"
|
Margin="0,24,0,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
IsHitTestVisible="False"
|
IsHitTestVisible="False"
|
||||||
IsVisible="{TemplateBinding Title,
|
IsVisible="{TemplateBinding Title,
|
||||||
Converter={x:Static ObjectConverters.IsNotNull}}"
|
Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||||
Text="{TemplateBinding Title}"
|
Text="{TemplateBinding Title}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
<Button
|
<Button
|
||||||
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
|
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="0,24,24,0"
|
Margin="0,24,24,0"
|
||||||
DockPanel.Dock="Right"
|
DockPanel.Dock="Right"
|
||||||
Theme="{DynamicResource CloseButton}" />
|
Theme="{DynamicResource CloseButton}" />
|
||||||
|
</Grid>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="2"
|
||||||
|
Margin="24,0,24,24"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Name="{x:Static u:DefaultDialogControl.PART_CancelButton}"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Classes="Tertiary"
|
||||||
|
Content="{DynamicResource STRING_MENU_DIALOG_CANCEL}" />
|
||||||
|
<Button
|
||||||
|
Name="{x:Static u:DefaultDialogControl.PART_NoButton}"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Classes="Danger"
|
||||||
|
Content="{DynamicResource STRING_MENU_DIALOG_NO}"
|
||||||
|
Theme="{DynamicResource SolidButton}" />
|
||||||
|
<Button
|
||||||
|
Name="{x:Static u:DefaultDialogControl.PART_YesButton}"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Classes="Primary"
|
||||||
|
Content="{DynamicResource STRING_MENU_DIALOG_YES}"
|
||||||
|
Theme="{DynamicResource SolidButton}" />
|
||||||
|
<Button
|
||||||
|
Name="{x:Static u:DefaultDialogControl.PART_OKButton}"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Classes="Primary"
|
||||||
|
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
|
||||||
|
Theme="{DynamicResource SolidButton}" />
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<StackPanel
|
</VisualLayerManager>
|
||||||
Grid.Row="2"
|
|
||||||
Margin="24,0,24,24"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
<Button
|
|
||||||
Name="{x:Static u:DefaultDialogControl.PART_CancelButton}"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Classes="Tertiary"
|
|
||||||
Content="{DynamicResource STRING_MENU_DIALOG_CANCEL}" />
|
|
||||||
<Button
|
|
||||||
Name="{x:Static u:DefaultDialogControl.PART_NoButton}"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Classes="Danger"
|
|
||||||
Content="{DynamicResource STRING_MENU_DIALOG_NO}"
|
|
||||||
Theme="{DynamicResource SolidButton}" />
|
|
||||||
<Button
|
|
||||||
Name="{x:Static u:DefaultDialogControl.PART_YesButton}"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Classes="Primary"
|
|
||||||
Content="{DynamicResource STRING_MENU_DIALOG_YES}"
|
|
||||||
Theme="{DynamicResource SolidButton}" />
|
|
||||||
<Button
|
|
||||||
Name="{x:Static u:DefaultDialogControl.PART_OKButton}"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Classes="Primary"
|
|
||||||
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
|
|
||||||
Theme="{DynamicResource SolidButton}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</Panel>
|
</Panel>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
|
|||||||
@@ -9,13 +9,15 @@ using Ursa.Common;
|
|||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
[TemplatePart(PART_CloseButton, typeof(Button))]
|
[TemplatePart(PART_CloseButton, typeof(Button))]
|
||||||
|
[TemplatePart(PART_TitleArea, typeof(Panel))]
|
||||||
public class DialogWindow: Window
|
public class DialogWindow: Window
|
||||||
{
|
{
|
||||||
public const string PART_CloseButton = "PART_CloseButton";
|
public const string PART_CloseButton = "PART_CloseButton";
|
||||||
|
public const string PART_TitleArea = "PART_TitleArea";
|
||||||
protected override Type StyleKeyOverride { get; } = typeof(DialogWindow);
|
protected override Type StyleKeyOverride { get; } = typeof(DialogWindow);
|
||||||
|
|
||||||
private Button? _closeButton;
|
private Button? _closeButton;
|
||||||
|
private Panel? _titleArea;
|
||||||
|
|
||||||
static DialogWindow()
|
static DialogWindow()
|
||||||
{
|
{
|
||||||
@@ -39,7 +41,10 @@ public class DialogWindow: Window
|
|||||||
{
|
{
|
||||||
base.OnApplyTemplate(e);
|
base.OnApplyTemplate(e);
|
||||||
EventHelper.UnregisterClickEvent(OnDefaultClose, _closeButton);
|
EventHelper.UnregisterClickEvent(OnDefaultClose, _closeButton);
|
||||||
|
_titleArea?.RemoveHandler(PointerPressedEvent, OnTitlePointerPressed);
|
||||||
_closeButton = e.NameScope.Find<Button>(PART_CloseButton);
|
_closeButton = e.NameScope.Find<Button>(PART_CloseButton);
|
||||||
|
_titleArea = e.NameScope.Find<Panel>(PART_TitleArea);
|
||||||
|
_titleArea?.AddHandler(PointerPressedEvent, OnTitlePointerPressed, RoutingStrategies.Bubble);
|
||||||
EventHelper.RegisterClickEvent(OnDefaultClose, _closeButton);
|
EventHelper.RegisterClickEvent(OnDefaultClose, _closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,8 +64,8 @@ public class DialogWindow: Window
|
|||||||
Close(null);
|
Close(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
private void OnTitlePointerPressed(object sender, PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
this.BeginMoveDrag(e);
|
this.BeginMoveDrag(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user