forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement EmptyView on UWP (xamarin#7438)
- Loading branch information
1 parent
2f9aff8
commit 8b34607
Showing
7 changed files
with
337 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Xamarin.Forms.Platform.UAP/CollectionView/FormsListView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
namespace Xamarin.Forms.Platform.UWP | ||
{ | ||
internal class FormsListView : Windows.UI.Xaml.Controls.ListView, IEmptyView | ||
{ | ||
ContentControl _emptyViewContentControl; | ||
FrameworkElement _emptyView; | ||
|
||
public Visibility EmptyViewVisibility | ||
{ | ||
get { return (Visibility)GetValue(EmptyViewVisibilityProperty); } | ||
set { SetValue(EmptyViewVisibilityProperty, value); } | ||
} | ||
|
||
public static readonly DependencyProperty EmptyViewVisibilityProperty = | ||
DependencyProperty.Register(nameof(EmptyViewVisibility), typeof(Visibility), typeof(FormsListView), new PropertyMetadata(Visibility.Collapsed)); | ||
|
||
public void SetEmptyView(FrameworkElement emptyView) | ||
{ | ||
_emptyView = emptyView; | ||
|
||
if (_emptyViewContentControl != null) | ||
{ | ||
_emptyViewContentControl.Content = emptyView; | ||
} | ||
} | ||
|
||
protected override void OnApplyTemplate() | ||
{ | ||
base.OnApplyTemplate(); | ||
|
||
_emptyViewContentControl = GetTemplateChild("EmptyViewContentControl") as ContentControl; | ||
|
||
if (_emptyView != null) | ||
{ | ||
_emptyViewContentControl.Content = _emptyView; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Windows.UI.Xaml; | ||
|
||
namespace Xamarin.Forms.Platform.UWP | ||
{ | ||
internal interface IEmptyView | ||
{ | ||
Visibility EmptyViewVisibility { get; set; } | ||
void SetEmptyView(FrameworkElement emptyView); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.