Basic dragging state for calendar control
This commit is contained in:
@@ -8,6 +8,9 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
d:DesignHeight="300"
|
d:DesignHeight="300"
|
||||||
d:DesignWidth="400"
|
d:DesignWidth="400"
|
||||||
|
CanDrag="True"
|
||||||
|
DragStarting="ControlDragStarting"
|
||||||
|
DropCompleted="ControlDropped"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Grid
|
<Grid
|
||||||
@@ -29,6 +32,18 @@
|
|||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
|
<VisualStateGroup x:Name="DraggingStates">
|
||||||
|
<VisualState x:Name="NotDragging" />
|
||||||
|
<VisualState x:Name="Dragging">
|
||||||
|
<VisualState.StateTriggers>
|
||||||
|
<StateTrigger IsActive="{x:Bind IsDragging, Mode=OneWay}" />
|
||||||
|
</VisualState.StateTriggers>
|
||||||
|
<VisualState.Setters>
|
||||||
|
<Setter Target="MainGrid.BorderThickness" Value="3" />
|
||||||
|
<Setter Target="MainGrid.BorderBrush" Value="Red" />
|
||||||
|
</VisualState.Setters>
|
||||||
|
</VisualState>
|
||||||
|
</VisualStateGroup>
|
||||||
<VisualStateGroup x:Name="EventDurationStates">
|
<VisualStateGroup x:Name="EventDurationStates">
|
||||||
<VisualState x:Name="RegularEvent" />
|
<VisualState x:Name="RegularEvent" />
|
||||||
<VisualState x:Name="AllDayEvent">
|
<VisualState x:Name="AllDayEvent">
|
||||||
|
|||||||
@@ -7,13 +7,20 @@ namespace Wino.Calendar.Controls
|
|||||||
{
|
{
|
||||||
public sealed partial class CalendarItemControl : UserControl
|
public sealed partial class CalendarItemControl : UserControl
|
||||||
{
|
{
|
||||||
|
public static readonly DependencyProperty CalendarItemProperty = DependencyProperty.Register(nameof(CalendarItem), typeof(ICalendarItem), typeof(CalendarItemControl), new PropertyMetadata(null, new PropertyChangedCallback(OnCalendarItemChanged)));
|
||||||
|
public static readonly DependencyProperty IsDraggingProperty = DependencyProperty.Register(nameof(IsDragging), typeof(bool), typeof(CalendarItemControl), new PropertyMetadata(false));
|
||||||
|
|
||||||
public ICalendarItem CalendarItem
|
public ICalendarItem CalendarItem
|
||||||
{
|
{
|
||||||
get { return (CalendarItemViewModel)GetValue(CalendarItemProperty); }
|
get { return (CalendarItemViewModel)GetValue(CalendarItemProperty); }
|
||||||
set { SetValue(CalendarItemProperty, value); }
|
set { SetValue(CalendarItemProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty CalendarItemProperty = DependencyProperty.Register(nameof(CalendarItem), typeof(ICalendarItem), typeof(CalendarItemControl), new PropertyMetadata(null, new PropertyChangedCallback(OnCalendarItemChanged)));
|
public bool IsDragging
|
||||||
|
{
|
||||||
|
get { return (bool)GetValue(IsDraggingProperty); }
|
||||||
|
set { SetValue(IsDraggingProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public CalendarItemControl()
|
public CalendarItemControl()
|
||||||
{
|
{
|
||||||
@@ -45,5 +52,9 @@ namespace Wino.Calendar.Controls
|
|||||||
VisualStateManager.GoToState(this, "RegularEvent", true);
|
VisualStateManager.GoToState(this, "RegularEvent", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ControlDragStarting(UIElement sender, DragStartingEventArgs args) => IsDragging = true;
|
||||||
|
|
||||||
|
private void ControlDropped(UIElement sender, DropCompletedEventArgs args) => IsDragging = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user