@@ -15,15 +15,15 @@ public DragAndDropBetweenLayouts()
15
15
void OnDragStarting ( object sender , DragStartingEventArgs e )
16
16
{
17
17
_emittedDragOver = false ;
18
- var label = ( Label ) ( sender as Element ) . Parent ;
18
+ var label = ( Label ) sender ;
19
19
var sl = label . Parent as StackLayout ;
20
20
e . Data . Properties . Add ( "Color" , label ) ;
21
21
e . Data . Properties . Add ( "Source" , sl ) ;
22
22
23
23
if ( sl == SLAllColors )
24
- SLRainbow . Background = SolidColorBrush . LightBlue ;
24
+ SLRainbow . Background = Brush . LightBlue ;
25
25
else
26
- SLAllColors . Background = SolidColorBrush . LightBlue ;
26
+ SLAllColors . Background = Brush . LightBlue ;
27
27
28
28
dragStartEvent . Text = "DragStarting" ;
29
29
@@ -34,12 +34,12 @@ void OnDragStarting(object sender, DragStartingEventArgs e)
34
34
35
35
void OnDropCompleted ( object sender , DropCompletedEventArgs e )
36
36
{
37
- var sl = ( sender as Element ) . Parent . Parent as StackLayout ;
37
+ var sl = ( ( Element ) sender ) . Parent as StackLayout ;
38
38
39
39
if ( sl == SLAllColors )
40
- SLRainbow . Background = SolidColorBrush . White ;
40
+ SLRainbow . Background = Brush . White ;
41
41
else
42
- SLAllColors . Background = SolidColorBrush . White ;
42
+ SLAllColors . Background = Brush . White ;
43
43
44
44
dragCompletedEvent . Text = "DropCompleted" ;
45
45
}
@@ -49,15 +49,14 @@ void OnDragOver(object sender, DragEventArgs e)
49
49
if ( ! e . Data . Properties . ContainsKey ( "Source" ) )
50
50
return ;
51
51
52
- //e.AcceptedOperation = DataPackageOperation.None;
53
- var sl = ( StackLayout ) ( sender as Element ) . Parent ;
52
+ var sl = ( ( StackLayout ) sender ) ;
54
53
if ( e . Data . Properties [ "Source" ] == sl )
55
54
{
56
55
e . AcceptedOperation = DataPackageOperation . None ;
57
56
return ;
58
57
}
59
58
60
- sl . Background = SolidColorBrush . LightPink ;
59
+ sl . Background = Brush . LightPink ;
61
60
62
61
if ( ! _emittedDragOver ) // This can generate a lot of noise, only add it once
63
62
{
@@ -75,14 +74,14 @@ void OnDragLeave(object sender, DragEventArgs e)
75
74
if ( ! e . Data . Properties . ContainsKey ( "Source" ) )
76
75
return ;
77
76
78
- var sl = ( StackLayout ) ( sender as Element ) . Parent ;
77
+ var sl = ( StackLayout ) sender ;
79
78
if ( e . Data . Properties [ "Source" ] == sl )
80
79
{
81
80
e . AcceptedOperation = DataPackageOperation . None ;
82
81
return ;
83
82
}
84
83
85
- sl . Background = SolidColorBrush . LightBlue ;
84
+ sl . Background = Brush . LightBlue ;
86
85
87
86
dragLeaveEvent . Text = "DragLeave" ;
88
87
}
@@ -92,7 +91,7 @@ void OnDrop(object sender, DropEventArgs e)
92
91
if ( ! e . Data . Properties . ContainsKey ( "Source" ) )
93
92
return ;
94
93
95
- var sl = ( sender as Element ) . Parent as StackLayout ;
94
+ var sl = ( StackLayout ) sender ;
96
95
if ( e . Data . Properties [ "Source" ] == sl )
97
96
{
98
97
return ;
@@ -116,13 +115,13 @@ void OnDrop(object sender, DropEventArgs e)
116
115
dropRelativeScreen . Text = $ "Drop relative to screen: { ( int ) e . GetPosition ( null ) . Value . X } ,{ ( int ) e . GetPosition ( null ) . Value . Y } ";
117
116
dropRelativeLabel . Text = $ "Drop relative to this label: { ( int ) e . GetPosition ( dropRelativeLabel ) . Value . X } ,{ ( int ) e . GetPosition ( dropRelativeLabel ) . Value . Y } ";
118
117
119
- SLAllColors . Background = SolidColorBrush . White ;
120
- SLRainbow . Background = SolidColorBrush . White ;
118
+ SLAllColors . Background = Brush . White ;
119
+ SLRainbow . Background = Brush . White ;
121
120
122
121
dropEvent . Text = "Drop" ;
123
122
}
124
123
125
- void ResetLayouts ( object sender , System . EventArgs e )
124
+ void ResetLayouts ( object sender , EventArgs e )
126
125
{
127
126
SLAllColors . Clear ( ) ;
128
127
SLRainbow . Clear ( ) ;
0 commit comments