I'm using CaliburnMicro in my WPF application, which uses an ExplorerBrowser control from WindowsAPICodePack (Microsoft-WindowsAPICodePack-Shell and Microsoft-WindowsAPICodePack-Core).
The events like SelectionChanged
attached to this control are not firing in the viewmodel.
I've tried it multiple ways with Caliburn's [Event] = [Action()]
, or making a simpler "WinForms" style event to the backing class of the view - none of these worked.
Caliburn events are working fine for any other controls in the view. So if I place an event on the parent Grid - it works.
The only way I found it does work, is accessing the control itself by name from code-behind, which isn't how I want do things.
I'm also not entirely clear on the syntax for the Caliburn event in this case, because it's accessible through Selector - [Event Selector.SelectionChanged]
.
I also tried catching it with different arg types and other events with same result.
Here's the View:
<UserControl x:Class="App.WinExplorer.WinExplorerView"
xmlns:WindowsAPICodePackPresentation="clr-namespace:Microsoft.WindowsAPICodePack.Controls.WindowsPresentationFoundation;assembly=Microsoft.WindowsAPICodePack.Shell"
xmlns:cal="http://www.caliburnproject.org"
...
<Grid>
<WindowsAPICodePackPresentation:ExplorerBrowser
x:Name="ExplorerBrowser"
NavigationTarget="{Binding NavigationTarget}"
cal:Message.Attach="[Event Selector.SelectionChanged] = [Action SelectionChanged($this, $eventArgs)]"
/>
</Grid>
</UserControl>
Here's the handler in the viewmodel:
public void SelectionChanged(object s, SelectionChangedEventArgs e)
{
// never hits this method
}
Tried declaring the event the reular WPF way too:
Selector.SelectionChanged="ExplorerBrowser_SelectionChanged"
What actually works but is a backwards way of doing it - inside the code-behind:
public partial class WinExplorerView : UserControl
{
public WinExplorerView()
{
InitializeComponent();
ExplorerBrowser.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;
}
private void SelectedItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
throw new System.NotImplementedException();
}
}
Any insight would be appreciated.