I have the following content in a Window
(removed unnecessary sections):
XAML:
<Style x:Key="itemstyle" TargetType="{x:Type ContentPresenter}">
<EventSetter Event="MouseLeftButtonDown" Handler="HandleItemClick"/>
</Style>
<ItemsControl ItemsSource="{Binding ArtistList}" Margin="10" Name="artist_list" ItemContainerStyle="{StaticResource itemstyle}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ID}" Foreground="White"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Controls:RSSViewer x:Name="rssControl" />
C# (Code Behind):
private void HandleItemClick(object sender, MouseButtonEventArgs e)
{
var selectedArtist = ((ContentPresenter) sender).Content as Artist;
rssControl.SourceUrl = "http://agnt666laptop:28666/rss.aspx?artistid=" + selectedArtist.ID;
}
Now what I want to do is convert the above mixture of xaml and C# to something that is purely and solely xaml, to take advantage of WPF's DataBinding model.
I think that it requires something like an Event trigger and combination of data binding with the selected item of the itemscontrol element or something like that, but I'm not sure on how to go about it.
Can anyone guide me to how I can convert the above solution to remove the procedural code?