I would like to post my NServiceBus subscripiton messages derived from an EventHandler class to a ListView. The ListView is located inside the MainWindow.xaml of the WPF application.
Here is my NServiceBus subscription event handler code. Note: I would like to post the event message to the ListView control in MainWindow.xaml. Any ideas?
namespace EventPublisher.SubscriberDemoWPF
{
public class PublishTrackEventHandler : IHandleMessages<PublishTrackEvent>
{
public void Handle(PublishTrackEvent message)
{
Trace.TraceInformation(message.GetType().Name);
//Need to post event message to ListView control in MainWindow.xaml UI;
}
}
}
Here is my MainWindow.xaml code, which is in the same namespace as my event handler code:
<Window x:Class="EventPublisher.SubscriberDemoWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ListView Height="260" HorizontalAlignment="Left" Margin="12,12,0,0" Name="lstEvents" VerticalAlignment="Top" Width="479" />
</Grid>
</Window>
Here is the MainWindow.xaml.cs code (typical):
namespace EventPublisher.SubscriberDemoWPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
//Would normally use listview.items.add("messages");
}
}