I have Button inside application.resources DataTemplate:
<DataTemplate x:Key="contactItem" DataType="{x:Type Model:Contact}">
<Button x:Name="openButton" Style="{StaticResource openButton}"/>
</DataTemplate>
How can I handle openButton click in UserControl?
<ItemsControl ItemSource="{Binding CurrentContacts}" ItemTemplate="{StaticResource contactItem}">
</ItemsControl>
You can add
ButtonBase.Clickhandler toItemsControl.Inside that event handler’s code you can use the
DataContextproperty ofe.OriginalSource(it should be of typeButton) to access data bound object.