Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to use binding, you'll need an <code>ItemsControl</code>, like <code>ListBox</code> and modify its <code>ItemsPanelTemplate</code> to use <code>Grid</code>. If you don't know the number of columns and rows, unfortunately you'll have to generate them manually from code. Or implement your own <code>Panel</code> completely.</p> <p>Here's the sample. You'll have to change all bindings from XPath if your underlying model is not XML.</p> <pre><code>&lt;Window x:Class="CoordBinding.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"&gt; &lt;Window.Resources&gt; &lt;XmlDataProvider x:Key="_items"&gt; &lt;x:XData&gt; &lt;Items xmlns=""&gt; &lt;Item ColId="1" RowId="2"&gt;Blah&lt;/Item&gt; &lt;Item ColId="0" RowId="1"&gt;Doh&lt;/Item&gt; &lt;Item ColId="2" RowId="0"&gt;Meh&lt;/Item&gt; &lt;/Items&gt; &lt;/x:XData&gt; &lt;/XmlDataProvider&gt; &lt;/Window.Resources&gt; &lt;ListBox ItemsSource="{Binding Source={StaticResource _items},XPath=Items/*}"&gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;Grid IsItemsHost="True"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition/&gt; &lt;ColumnDefinition/&gt; &lt;ColumnDefinition/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition/&gt; &lt;RowDefinition/&gt; &lt;RowDefinition/&gt; &lt;/Grid.RowDefinitions&gt; &lt;/Grid&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;ListBox.Resources&gt; &lt;Style TargetType="ListBoxItem"&gt; &lt;Setter Property="Grid.Row" Value="{Binding XPath=@RowId}" /&gt; &lt;Setter Property="Grid.Column" Value="{Binding XPath=@ColId}" /&gt; &lt;/Style&gt; &lt;/ListBox.Resources&gt; &lt;/ListBox&gt; &lt;/Window&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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