0

In my XAML I got this

<UniformGrid x:Name="gameGrid" Columns="{Binding GridColumnSize}"  Rows="{Binding GridRowSize}"/>

and I want to bind the values to these in my code so I can change them

public int GridColumnSize = 5;
public int GridRowSize = 7;

It doesn't work though. When I put there for example 35 buttons it will display 6 * 6 grid, since that's how it acts normally. So how do I bind it? Or is there another way?

ZyLacx
  • 1
  • Where are `GridColumnSize` and `GridRowSize` defined? Did you set a proper data context to use them via Binding? – Pavel Anikhouski Feb 23 '20 at 14:51
  • I have no idea how does this work and it's defined in the MainWindow.xaml.cs – ZyLacx Feb 23 '20 at 14:56
  • I also tried this Binding GridRowSize = new Binding(Convert.ToString(gameGrid.Rows)); GridRowSize.Source = RowSize; gameGrid.SetBinding(gameGrid.Rows, GridRowSize); I converted the gameGrid.Rows first time because it said that it can't convert int to string. Now it's okay I think but the last gameGrid.Rows says that it can't convert int to System.Windows.DependencyProperty – ZyLacx Feb 23 '20 at 14:58

0 Answers0