ListBox, how to repaint in a different color when you select an item?

Hello,
I can not understand how the internal ListBox in a different color

<listbox x:name="vks" horizontalalignment="Center" verticalalignment="Center" selectionchanged="vks_SelectionChanged" selectionmode="Multiple" itemssource="{Binding}" isdoubletapenabled="False" isholdingenabled="False" isrighttapenabled="False" istapenabled="False" manipulationmode="All" foreground="Black" background="Black">

<listbox.itemtemplate>
<datatemplate>
 <stackpanel horizontalalignment="Center" verticalalignment="Center" background="Black">
 <textblock text="{Binding ShortText}" verticalalignment="Center" horizontalalignment="Center" foreground="{ThemeResource AppBarItemForegroundThemeBrush}">
 <listbox itemssource="{Binding mImages}" horizontalalignment="Center" verticalalignment="Center" selectionchanged="vks_SelectionChanged" selectionmode="Multiple" requestedtheme="Dark" foreground="Black" background="Black" borderbrush="Black">

<listbox.itemtemplate>
<datatemplate>
 <stackpanel horizontalalignment="Center" verticalalignment="Center" background="Black">
 <textblock text="{Binding linkMaxImage}" verticalalignment="Center" horizontalalignment="Center">
 <textblock text="{Binding linkMaxImage}" verticalalignment="Center" horizontalalignment="Center">
</textblock></textblock></stackpanel>
</datatemplate>
</listbox.itemtemplate>
</listbox>
</textblock></stackpanel>
</datatemplate>
</listbox.itemtemplate>
 </listbox>


Also noticed when setting IsEnabled="False" outer frame appears , too, that you don't know how to repaint.

Please help , thanks in advance
September 19th 19 at 00:13
1 answer
September 19th 19 at 00:15
Solution
One of the options.

<!-- Create a style that is overriding the system highlight color of a ListboxItem-->
<style x:key="vksStyle" targettype="{x:Type ListBoxItem}">
<Style.Resources>
 <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Green"/>
</Style.Resources>
</style>

<!--Assign the above created style of our ListBox ItemContainerStyle-->
<listbox itemssource="{Binding}" itemcontainerstyle="{StaticResource vksStyle}"></listbox>
Thanks for the reply.
Doing so
<page.resources>
 <style x:key="vksStyle" targettype="{x:Type ListBoxItem}">
<Style.Resources>
 <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Green"/>
</Style.Resources>
</style>
 </page.resources>

indicates an error "Type not supported in a Windows App project" and in a Style not found the Resources property
Tried immediately inside the ListBox
<listbox.itemcontainerstyle>
<style>
<Style.Resources>
 <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Green"/>
</Style.Resources>
</style>
 </listbox.itemcontainerstyle>
this error on Resourses and on the x:Static is not found

Before this, also tried this, with examples taken from the Internet.... - samant commented on September 19th 19 at 00:18
What type of application? WPF, Windows Phone, Windows Store? - martina40 commented on September 19th 19 at 00:21
I have just started programming in C# . so I could be wrong in the name in Visual Studio created the project "Universal app", as I understand it from Windows 8.1 and WindowsPhone8.1 . So far, all dances with a tambourine around Windows 8.1 - samant commented on September 19th 19 at 00:24
Sketched example: 1drv.ms/1zXtrSJ

In it, I overwrote the container-style ListBox

- martina40 commented on September 19th 19 at 00:27
XAML already looked. Here is the answer so the answer. Thank You very much! - samant commented on September 19th 19 at 00:30
No problem :) If I have more questions, feel free to ask them on my email. - martina40 commented on September 19th 19 at 00:33
: and also thank you :) I have really a lot of questions, but I am ashamed of the court to write (I write the post 2 days torment), let alone You personally on e-mail, so until I try it myself. But thanks anyway :) - samant commented on September 19th 19 at 00:36
When I started to study, I do not have anyone it was too much to ask, in addition to stackoverflow. So don't hesitate. A bad question is the one not asked. - martina40 commented on September 19th 19 at 00:39

Find more questions by tags C#WindowsXAML