Skip to content

Commit d766b9e

Browse files
committed
Initial commit
1 parent 84adf91 commit d766b9e

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ViewportBehavior/ViewportBehaviorPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
88
mc:Ignorable="d">
99
<Page.Resources>
10-
<behaviors:ViewportBehavior x:Key="ViewportBehavior" />
10+
<behaviors:ViewportBehavior x:Key="ViewportBehavior" IsAlwaysOn="True"/>
1111
</Page.Resources>
1212

1313
<Grid>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Windows.UI.Xaml;
2+
3+
namespace Microsoft.Toolkit.Uwp.UI.Behaviors
4+
{
5+
public partial class ViewportBehavior
6+
{
7+
public static readonly DependencyProperty IsAlwaysOnProperty =
8+
DependencyProperty.Register(nameof(IsAlwaysOn), typeof(bool), typeof(ViewportBehavior), new PropertyMetadata(true));
9+
10+
/// <summary>
11+
/// Gets or sets a value indicating whether this behavior will remain attached after the associated element enters the viewport. When false, the behavior will remove itself after entering.
12+
/// </summary>
13+
public bool IsAlwaysOn
14+
{
15+
get { return (bool)GetValue(IsAlwaysOnProperty); }
16+
set { SetValue(IsAlwaysOnProperty, value); }
17+
}
18+
}
19+
}

Microsoft.Toolkit.Uwp.UI.Behaviors/Viewport/ViewportBehavior.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
1414
/// <summary>
1515
/// A class for listening element enter or exit the ScrollViewer viewport
1616
/// </summary>
17-
public class ViewportBehavior : BehaviorBase<FrameworkElement>
17+
public partial class ViewportBehavior : BehaviorBase<FrameworkElement>
1818
{
1919
/// <summary>
2020
/// The ScrollViewer hosting this element.
@@ -36,8 +36,8 @@ public class ViewportBehavior : BehaviorBase<FrameworkElement>
3636
/// <summary>
3737
/// The IsAlwaysOn value of the associated element
3838
/// </summary>
39-
public static readonly DependencyProperty IsAlwaysOnProperty =
40-
DependencyProperty.Register(nameof(IsAlwaysOn), typeof(bool), typeof(ViewportBehavior), new PropertyMetadata(default(bool)));
39+
//public static readonly DependencyProperty IsAlwaysOnProperty =
40+
// DependencyProperty.Register(nameof(IsAlwaysOn), typeof(bool), typeof(ViewportBehavior), new PropertyMetadata(true));
4141

4242
/// <summary>
4343
/// Associated element fully enter the ScrollViewer viewport event
@@ -59,14 +59,14 @@ public class ViewportBehavior : BehaviorBase<FrameworkElement>
5959
/// </summary>
6060
public event EventHandler ExitingViewport;
6161

62-
/// <summary>
63-
/// Gets or sets a value indicating whether this behavior will remain attached after the associated element enters the viewport. When false, the behavior will remove itself after entering.
64-
/// </summary>
65-
public bool IsAlwaysOn
66-
{
67-
get { return (bool)GetValue(IsAlwaysOnProperty); }
68-
set { SetValue(IsAlwaysOnProperty, value); }
69-
}
62+
///// <summary>
63+
///// Gets or sets a value indicating whether this behavior will remain attached after the associated element enters the viewport. When false, the behavior will remove itself after entering.
64+
///// </summary>
65+
//public bool IsAlwaysOn
66+
//{
67+
// get { return (bool)GetValue(IsAlwaysOnProperty); }
68+
// set { SetValue(IsAlwaysOnProperty, value); }
69+
//}
7070

7171
/// <summary>
7272
/// Gets a value indicating whether associated element is fully in the ScrollViewer viewport

0 commit comments

Comments
 (0)