diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTrigger.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTrigger.bind
index 51ccd36ebef..8c812d09637 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTrigger.bind
+++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTrigger.bind
@@ -33,6 +33,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -43,7 +55,7 @@
-
+
@@ -63,7 +75,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTriggerPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTriggerPage.xaml.cs
index 7068f902dcb..0d80726099b 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTriggerPage.xaml.cs
+++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTriggerPage.xaml.cs
@@ -16,6 +16,8 @@ public sealed partial class IsNullOrEmptyStateTriggerPage : Page, IXamlRenderLis
private Button _addButton;
private Button _removeButton;
private ListBox _listBox;
+ private Button _unselectButton;
+ private ListView _selectListView;
///
/// Initializes a new instance of the class.
@@ -52,6 +54,15 @@ public void OnXamlRendered(FrameworkElement control)
}
_listBox = control.FindDescendant("OurList") as ListBox;
+
+ _selectListView = control.FindDescendant("SelectList") as ListView;
+
+ if (control.FindDescendant("RemoveSelection") is Button btn3)
+ {
+ _unselectButton = btn3;
+
+ _unselectButton.Click += this.UnselectButton_Click;
+ }
}
private void AddButton_Click(object sender, RoutedEventArgs e)
@@ -64,10 +75,18 @@ private void AddButton_Click(object sender, RoutedEventArgs e)
private void RemoveButton_Click(object sender, RoutedEventArgs e)
{
- if (_listBox != null)
+ if (_listBox != null && _listBox.Items.Count > 0)
{
_listBox.Items.RemoveAt(0);
}
}
+
+ private void UnselectButton_Click(object sender, RoutedEventArgs e)
+ {
+ if(_selectListView != null && _selectListView.SelectedItem != null)
+ {
+ _selectListView.SelectedItem = null;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Microsoft.Toolkit.Uwp.UI/Triggers/IsNullOrEmptyStateTrigger.cs b/Microsoft.Toolkit.Uwp.UI/Triggers/IsNullOrEmptyStateTrigger.cs
index 7eec265e229..fb49e0ecfb1 100644
--- a/Microsoft.Toolkit.Uwp.UI/Triggers/IsNullOrEmptyStateTrigger.cs
+++ b/Microsoft.Toolkit.Uwp.UI/Triggers/IsNullOrEmptyStateTrigger.cs
@@ -28,22 +28,28 @@ public object Value
/// Identifies the DependencyProperty
///
public static readonly DependencyProperty ValueProperty =
- DependencyProperty.Register(nameof(Value), typeof(object), typeof(IsNullOrEmptyStateTrigger), new PropertyMetadata(true, OnValuePropertyChanged));
+ DependencyProperty.Register(nameof(Value), typeof(object), typeof(IsNullOrEmptyStateTrigger), new PropertyMetadata(null, OnValuePropertyChanged));
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public IsNullOrEmptyStateTrigger()
+ {
+ SetActive(true);
+ }
private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var obj = (IsNullOrEmptyStateTrigger)d;
var val = e.NewValue;
- obj.SetActive(IsNullOrEmpty(val));
-
if (val == null)
{
return;
}
// Try to listen for various notification events
- // Starting with INorifyCollectionChanged
+ // Starting with INotifyCollectionChanged
var valNotifyCollection = val as INotifyCollectionChanged;
if (valNotifyCollection != null)
{