The effect after setting is
1 code in the form
<window x:class= "Qynodetest.mainwindow"
Xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"
Title= "MainWindow" height= "width=" 525 ">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<resourcedictionary source= "Style/style.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<listbox style= "{StaticResource listboxhor}" >
<ListBoxItem>
<Border>
<StackPanel>
<textblock horizontalalignment= "Center" > Project 1</textblock>
<button content= "OK" width= "horizontalalignment=" Center/>
</StackPanel>
</Border>
</ListBoxItem>
<ListBoxItem>
<Border>
<StackPanel>
<textblock horizontalalignment= "Center" > Project 1</textblock>
<button content= "OK" width= "horizontalalignment=" Center/>
</StackPanel>
</Border>
</ListBoxItem>
<ListBoxItem>
<Border>
<StackPanel>
<textblock horizontalalignment= "Center" > Project 1</textblock>
<button content= "OK" width= "horizontalalignment=" Center/>
</StackPanel>
</Border>
</ListBoxItem>
<ListBoxItem>
<Border>
<StackPanel>
<textblock horizontalalignment= "Center" > Project 1</textblock>
<button content= "OK" width= "horizontalalignment=" Center/>
</StackPanel>
</Border>
</ListBoxItem>
</ListBox>
</Grid>
</Window>
2 code in style files
<!--set the listbox style--
<style targettype= "ListBox" x:key= "Listboxhor" >
<!--setting up a template--
<setter property= "Template" >
<Setter.Value>
<controltemplate targettype= "ListBox" >
<scrollviewer horizontalscrollbarvisibility= "Disabled" verticalscrollbarvisibility= "Auto" >
<wrappanel orientation= "Horizontal" isitemshost= "true" scrollviewer.cancontentscroll= "true"/>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--set ListBoxItem style --
<style targettype= "ListBoxItem" >
<setter property= "Width" value= "></Setter>"
<setter property= "Height" value= "></Setter>"
<setter property= "Margin" value= "5" ></Setter>
<setter property= "BorderBrush" value= "Red"/>
<setter property= "BorderThickness" value= "1"/>
<!--set the control template--
<setter property= "Template" >
<Setter.Value>
<controltemplate targettype= "ListBoxItem" >
<border background= "{TemplateBinding Background}" borderbrush= "{TemplateBinding BorderBrush}" borderthickness= "{ TemplateBinding borderthickness} ">
<contentpresenter horizontalalignment= "Center" verticalalignment= "{TemplateBinding verticalcontentalignment}" Textblock.foreground= "{TemplateBinding Foreground}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<!--setting Triggers--
<Style.Triggers>
<trigger property= "IsSelected" value= "true" >
<setter property= "Background" value= "#808080"/>
<setter property= "Foreground" value= "white"/>
<setter property= "BorderBrush" value= "Green"/>
<setter property= "BorderThickness" value= "2"/>
</Trigger>
<trigger property= "IsMouseOver" value= "true" >
<setter property= "Background" value= "Red"/>
<setter property= "BorderBrush" value= "Black"/>
<setter property= "BorderThickness" value= "2"/>
</Trigger>
</Style.Triggers>
</Style>
Style settings for a listbox in WPF