How does one inherit styles

Oct 31, 2013 at 10:18 PM
Edited Oct 31, 2013 at 10:19 PM
When binding to ListBox, I would need to do the following code:
<ListBox x:Name="TotalItems" DisplayMemberPath="EnglishName" Margin="130,38,0,78">
    <ListBox.ItemContainerStyle> fixes things, but removes style
        <Style TargetType="{x:Type ListBoxItem}">
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>
This is to remove this error shown in this post:
http://stackoverflow.com/questions/3958173/listboxitem-produces-system-windows-data-error-4-binding-error

However, when setting ItemContainerStyle, it overrites the nice Elysium style! Is there a way to preserve the style?

Thanks
Coordinator
Nov 1, 2013 at 12:31 AM
Nov 1, 2013 at 6:57 PM
<Style x:Key="Style2" BasedOn="{StaticResource Style1}">
What would Style1 be for Elysium?

Should I do:
BasedOn="{StaticResource Elysium}"
Like that?
Coordinator
Nov 1, 2013 at 8:01 PM
<ListBox x:Name="TotalItems" DisplayMemberPath="EnglishName" Margin="130,38,0,78">
    <ListBox.ItemContainerStyle> fixes things, but removes style
        <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>