-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
Description
I'm trying to detect when an ObservableCollection is not empty and enable a clear command only in that case
Repro steps
I've tried the following
let clearRecentsCmd =
self.Factory.CommandSyncChecked(
(fun () -> self.ClearRecents()),
(fun () -> self.RecentsNotEmpty ),
[ <@@ self.RecentsNotEmpty @@>; <@@ self.Recents @@>])
let recents = self.Factory.Backing(<@ self.Recents @>, ObservableCollection<RecentFile>(getRecent()))
do
self.DependencyTracker.AddPropertyDependencies(<@@ self.RecentsNotEmpty @@>, [ <@@ self.Recents @@> ; ])
member x.Recents with get() = recents.Value and set value = recents.Value <- value
member x.Add2Recents r =
x.Recents.Insert(0,r)
member x.ClearRecents() =
x.Recents.Clear()
member x.RecentsNotEmpty with get() = x.Recents.Count > 0
Expected behavior
x.Recents.Insert(0,r)
should raise a Command
CanExecuteChanged
Actual behavior
The command doesn't get enabled if I add a new RecentFile
to the empty ObservableCollection
.
Known workarounds
I'm forced to use the clumsy x.Recents <- ObservableCollection(r :: (x.Recents |> Seq.toList))
instead of x.Recents.Insert(0,r)
Related information
I'm using .Net Framework 4.6.1 and F# 4.4.3
Metadata
Metadata
Assignees
Labels
No labels