1. Silverlight has different syntax for
Style.TargetType
property, use
<style targettype="FrameworkElement"></style>
(
Style.TargetType Property).
2. Binding in the property setters has been added in Silverlight 5. So if you use SL4, it won't work.
3. There is no
ItemContainerStyle
property on the
ItemsControl
. It exists on derived controls such as
ListBox
. If you don't need some ListBox-specific behavior, such as selection, use simplified
ListBoxItem
control template, for example:
<Style TargetType="ListBoxItem">
<Setter Property="Grid.Row" Value="{Binding Row}"/>
<Setter Property="Grid.Column" Value="{Binding Column}"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter x:Name="contentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>