Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In my tests, changing the ItemTemplate (TaskListTemplate) did not have any effect. So the first step would be to do this in another way, I chose setting the ContentTemplate in the ListBoxItemStyle, which worked. Further, you want some rounded rectangle with an alternating background: I used a border for this in my modification of your code, but a rectangle would also work out similarly. Here I think, the key is to set the background of other elements transparent, otherwise they will hide your rectangle. Just copy the following code in Kaxaml to see what it looks like.</p> <pre><code>&lt;Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;Page.Resources&gt; &lt;DataTemplate x:Key="TaskListTemplate"&gt; &lt;Border MinWidth="50" Height="70" Background="{TemplateBinding ListBoxItem.Background}" BorderBrush="Black" CornerRadius="8" Margin="0"&gt; &lt;Grid Background="Transparent"&gt; &lt;TextBox x:Name="txtDescription" Text="{Binding Path=Des}" Background="Transparent"/&gt; &lt;TextBox x:Name="txtComments" Text="{Binding Path=Com}" Background="Transparent"/&gt; &lt;Label Content="{Binding Path=Title}" Background="Transparent"/&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}"&gt; &lt;Setter Property="FontSize" Value="12"/&gt; &lt;Setter Property="FontFamily" Value="Tahoma"/&gt; &lt;Setter Property="Background" Value="#006C3B3B"/&gt; &lt;Setter Property="ContentTemplate" Value="{DynamicResource TaskListTemplate}"/&gt; &lt;Style.Resources&gt; &lt;SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF533F70"/&gt; &lt;SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FF533F70"/&gt; &lt;Storyboard x:Key="MouseOverStoryBoard"&gt; &lt;ColorAnimationUsingKeyFrames AutoReverse="True" BeginTime="00:00:00" Storyboard.TargetName="{x:Null}" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"&gt; &lt;SplineColorKeyFrame KeyTime="00:00:00" Value="#FFF48F21"/&gt; &lt;SplineColorKeyFrame KeyTime="00:00:00.500" Value="#FF4A475C"/&gt; &lt;/ColorAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/Style.Resources&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="ItemsControl.AlternationIndex" Value="0"&gt; &lt;Setter Property="Background"&gt; &lt;Setter.Value&gt; &lt;SolidColorBrush Color="#FFA2BAD4"/&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="Foreground" Value="White"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="ItemsControl.AlternationIndex" Value="1"&gt; &lt;Setter Property="Background" Value="#FF7395B9"/&gt; &lt;Setter Property="Foreground" Value="White"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Trigger.EnterActions&gt; &lt;BeginStoryboard Storyboard="{StaticResource MouseOverStoryBoard}"/&gt; &lt;/Trigger.EnterActions&gt; &lt;Setter Property="Foreground" Value="White"/&gt; &lt;Setter Property="Background" Value="#FFF48F21"/&gt; &lt;Setter Property="FontStyle" Value="Normal"/&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Page.Resources&gt; &lt;Grid&gt; &lt;ListBox Margin="8,37,0,6" ItemContainerStyle="{DynamicResource ListBoxItemStyle}" AlternationCount="2"&gt; &lt;ListBoxItem&gt;Test1&lt;/ListBoxItem&gt; &lt;ListBoxItem&gt;Test2&lt;/ListBoxItem&gt; &lt;ListBoxItem&gt;Test3&lt;/ListBoxItem&gt; &lt;/ListBox&gt; &lt;/Grid&gt; &lt;/Page&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload