You can place it in the resource collection at the appropriate level. For example, if you want an application area, put it in App.xaml .
eg.
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml" > <Application.Resources> <Style TargetType="ListBoxItem"> <Setter Property="Template"> ... </Setter> </Style> </Application.Resources> </Application>
You can specify your resource keys, and then set the corresponding style property using the corresponding key, for example. define your style with the key:
<Style x:Key="MyStyle" TargetType="ListBoxItem">
and use the resource by key:
<ListBox x:Name="lstItems" ItemContainerStyle="{StaticResource MyStyle}">
source share