--- title: "How to: Use Triggers to Style Selected Items in a ListView" ms.date: "03/30/2017" helpviewer_keywords: - "ListView controls [WPF], styling" ms.assetid: 1e2bdce0-afe8-4507-9b18-f33de43de25a --- # How to: Use Triggers to Style Selected Items in a ListView This example shows how to define for a control so that when a property value of a changes, the of the changes in response. ## Example If you want the of a to change in response to property changes, define for the change. The following example defines a that sets the property to and changes the to display a when the property changes to `true`. [!code-xaml[ListViewChkBox#ListViewItemTriggersStart](~/samples/snippets/csharp/VS_Snippets_Wpf/ListViewChkBox/CS/window1.xaml#listviewitemtriggersstart)] [!code-xaml[ListViewChkBox#Trigger](~/samples/snippets/csharp/VS_Snippets_Wpf/ListViewChkBox/CS/window1.xaml#trigger)] [!code-xaml[ListViewChkBox#ListViewItemTriggersEnd](~/samples/snippets/csharp/VS_Snippets_Wpf/ListViewChkBox/CS/window1.xaml#listviewitemtriggersend)] The following example defines a that sets the property of a to when the is the selected item and has keyboard focus. [!code-xaml[ListViewChkBox#ListViewItemTriggersStart](~/samples/snippets/csharp/VS_Snippets_Wpf/ListViewChkBox/CS/window1.xaml#listviewitemtriggersstart)] [!code-xaml[ListViewChkBox#MultiTrigger](~/samples/snippets/csharp/VS_Snippets_Wpf/ListViewChkBox/CS/window1.xaml#multitrigger)] [!code-xaml[ListViewChkBox#ListViewItemTriggersEnd](~/samples/snippets/csharp/VS_Snippets_Wpf/ListViewChkBox/CS/window1.xaml#listviewitemtriggersend)] ## See also - - - - [How-to Topics](listview-how-to-topics.md) - [ListView Overview](listview-overview.md) - [GridView Overview](gridview-overview.md)