Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this converter. XAML look a little bit complicated, but no ViewModel(s) or UserControl(s) are required:</p> <p>Converter to flip rows:</p> <pre><code>public class UpsideDownRowConverter : IMultiValueConverter { public int RowCount { get; set; } public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Length == 2 &amp;&amp; values[0] is int &amp;&amp; values[1] is int) { var row = (int)values[0]; var rowSpan = (int)values[1]; row = this.RowCount - row - rowSpan; return row; } return DependencyProperty.UnsetValue; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } </code></pre> <p>XAML. The first Grid is original, the second is flipped:</p> <pre><code>&lt;Window.Resources&gt; &lt;local:UpsideDownRowConverter x:Key="UpsideDownRowConverter" RowCount="3"/&gt; &lt;/Window.Resources&gt; &lt;UniformGrid Rows="2"&gt; &lt;Grid Name="Original" Margin="0,0,0,10"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition/&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;Rectangle Fill="Green" Grid.Column="0" Grid.Row="2"/&gt; &lt;Rectangle Fill="Red" Grid.Column="1" Grid.Row="1"/&gt; &lt;Rectangle Fill="Blue" Grid.Column="2" Grid.RowSpan="3"/&gt; &lt;Rectangle Fill="Yellow" Grid.Column="3" Grid.RowSpan="2"/&gt; &lt;/Grid&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition/&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;Rectangle Fill="Green" Grid.Column="0"&gt; &lt;Grid.Row&gt; &lt;MultiBinding Converter="{StaticResource UpsideDownRowConverter}"&gt; &lt;Binding Path="Children[0].(Grid.Row)" ElementName="Original"/&gt; &lt;Binding Path="(Grid.RowSpan)" RelativeSource="{RelativeSource Self}"/&gt; &lt;/MultiBinding&gt; &lt;/Grid.Row&gt; &lt;/Rectangle&gt; &lt;Rectangle Fill="Red" Grid.Column="1"&gt; &lt;Grid.Row&gt; &lt;MultiBinding Converter="{StaticResource UpsideDownRowConverter}"&gt; &lt;Binding Path="Children[1].(Grid.Row)" ElementName="Original"/&gt; &lt;Binding Path="(Grid.RowSpan)" RelativeSource="{RelativeSource Self}"/&gt; &lt;/MultiBinding&gt; &lt;/Grid.Row&gt; &lt;/Rectangle&gt; &lt;Rectangle Fill="Blue" Grid.Column="2" Grid.RowSpan="3"&gt; &lt;Grid.Row&gt; &lt;MultiBinding Converter="{StaticResource UpsideDownRowConverter}"&gt; &lt;Binding Path="Children[2].(Grid.Row)" ElementName="Original"/&gt; &lt;Binding Path="(Grid.RowSpan)" RelativeSource="{RelativeSource Self}"/&gt; &lt;/MultiBinding&gt; &lt;/Grid.Row&gt; &lt;/Rectangle&gt; &lt;Rectangle Fill="Yellow" Grid.Column="3" Grid.RowSpan="2"&gt; &lt;Grid.Row&gt; &lt;MultiBinding Converter="{StaticResource UpsideDownRowConverter}"&gt; &lt;Binding Path="Children[3].(Grid.Row)" ElementName="Original"/&gt; &lt;Binding Path="(Grid.RowSpan)" RelativeSource="{RelativeSource Self}"/&gt; &lt;/MultiBinding&gt; &lt;/Grid.Row&gt; &lt;/Rectangle&gt; &lt;/Grid&gt; &lt;/UniformGrid&gt; </code></pre> <p>Unfortunately, it is unable to pass row count as a third value, because RowDefinitionCollection doesn't notify about changes. That's why I added RowCount as property of converter.</p>
    singulars
    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. This table or related slice is empty.
    1. 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