Mr1Penguin
Mr1Penguin

Reputation: 43

xaml VisualState set Grid.Row/Column of element

I have a Grid Layout with 7 elements in row. I want to move last 4 elements from first row to second if windowScreenWidth less than X. I already added a group and states. If i use <Setter Target="el4.Grid.Row" Value="1"/> or <Setter Target="el4" Property="Grid.Row" Value="1"/> xaml throw exception.

Are there any way to make what i want?

Upvotes: 1

Views: 1400

Answers (2)

Nk54
Nk54

Reputation: 771

The right XAML code is: Target="el4.(Grid.Row)" Value="1"/>

A bit late, but might help other people. Because the solution given wasn't the best (using if instead of style and states).

Upvotes: 8

Mr1Penguin
Mr1Penguin

Reputation: 43

Found some workaround:

void WindowSizeChanged(object sender, SizeChangedEventArgs e)
{
  double width = e.NewSize.Width;
  if(width < 641)
  {
    el4.SetValue(Grid.RowProperty, 1);
    el4.SetValue(Grid.ColumnProperty, 0);
  }
  else
  {
    el4.SetValue(Grid.RowProperty, 0);
    el4.SetValue(Grid.ColumnProperty, 3);
  }
}

public MainPage()
{
  SizeChanged += WindowSizeChanged;
  this.InitializeComponent();
}

Upvotes: 0

Related Questions