Closing TabItem by clicking middle button
问题 I have a problem. In my WPF application, if i press a tabItem with middle mouse button, this tabItem should close. Just like in FireFox. But I try to do this using MVVM, and i need to use commands. Also my tabItems are created dynamically. Help me plz! Thank you! 回答1: Create a DataTemplate for your tab items like this: <DataTemplate x:Key="ClosableTabTemplate"> <Border> <Grid> <Grid.InputBindings> <MouseBinding Command="ApplicationCommands.Close" Gesture="MiddleClick" /> </Grid.InputBindings>