I would like to post Subscripiton messages from NServiceBus received from the EventHandler class in a ListView. The ListView is located inside the MainWindow.xaml of the WPF application.
Here is my NServiceBus subscription event handler code. Note. I want to post an event message in a 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);
Here is my MainWindow.xaml code, which is in the same namespace as the code of my event handler:
<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"); } }
source share