I have the following XAML:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.RowDefinitions>
...
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
...
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
...
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Grid.Row" Value="{Binding Row, Mode=OneWay}" />
<Setter Property="Grid.Column" Value="{Binding Column, Mode=OneWay}" />
</Style>
</ListBox.ItemContainerStyle>
...
When the page loads, I'm getting the following XamlParseException
:
Failed to assign to property 'System.Windows.Setter.Value'. [Line: 69 Position: 63]
InnerException:
NotSupportedException: Cannot set read-only property ''.
The line number in the error corresponds to the Grid.Row
setter; if I put a hard-coded value instead of a binding, it works fine (but obviously it's not what I want).
What's going on? The inner exception message makes no sense; I'm not setting any read-only property, and I'm certainly not setting a property with no name!
I'm new to Windows Phone, but I'm pretty sure the same code would work fine in WPF... Is binding in a setter not supported on WP?