我有一个ListBox,其中定义了ListBoxItems的样式。在这个样式中,我有一些标签和一个按钮。在按钮上,我想定义一个可在我的页面上处理的点击事件(或使用该样式的任何页面)。如何在我的WPF页面上创建事件处理程序以处理来自ListBoxItems样式的事件?
这是我的样式(仅影响代码):
<Style x:Key="UsersTimeOffList" TargetType="{x:Type ListBoxItem}">
...
<Grid>
<Button x:Name="btnRemove" Content="Remove" Margin="0,10,40,0" Click="btnRemove_Click" />
</Grid>
</Style>
感谢您!