2
votes

I have a WPF Tab Control. Inside of it is a Listbox filled with some items. (There is only one item represented in the picture):

unselected item

The item has an orange gradient.

And here is the same item once I select it with the mouse:

unselected item

My area of interest is the little left side sliver of Blue coloring that I have circled in red. I realize that this is the product of me selecting the item, and it shades the entire item blue to signify this. However you will notice that this sliver of blue is not located in any of the edges except the left side.

My question is this: How can I stretch the left side of my listbox item such that this blue sliver is gone, and the orange from the listbox item fills that area? I have played with margins and padding on everything I can think of, but to no avail.

Any hints, comments, and suggestions are much appreciated! :)

EDIT: As requested, the Xaml for the ItemTemplate.

The ItemTemplate uses a DataTemplate that is a static Resource. The DataTemplate looks like this:

    <DataTemplate x:Key="MyDataTemplate">
        <UserControl MouseDoubleClick="MouseDoubleClick_Event">
            <DockPanel Background="<the orange gradient>" LastChildFill="True">
                <Image Name="AnImage" Height="20" Width="20" Source=" Binding Path=ImagePath}"/>
                <Label Width="Auto">
                    <TextBlock Text="{Binding Path=TheName}" />
                </Label>
            </DockPanel>
        </UserControl>
    </DataTemplate>
2
Can you show the pertinent XAML for this ItemTemplate?Jay
I have edited it with the requested information! Thank you for taking an interest in my question!mherr

2 Answers

2
votes

I'm pretty sure the problem is with your TabControl container, which you don't put, anyway, just set Padding to zero on the TabControl:

<TabControl Margin="0" Padding="0">

TabControl's Default Style sets the Padding to 4 (that's the inner margin you are seeing) and binds the Margin on the content host to the Padding on the TabControl.

-1
votes

I have found a solution to this. If I simply set a negative left margin on my ListBox, it moves the ListBoxItems over that amount and the sliver disappears. Thanks to everyone for your interest!