I have a grid, which I build dynamically and while building I put an image in the first cell (0, 0) in the grid.
I want to use data binding so that when the users change the position, the image will change its position to the right place in the grid.
The user has 2 texboxes which there he put the row and column in the grid.
Any help will be appreciated.
Edit: The code I did so far: View: I have a window that contains thisuser controller
public MyController()
{
InitializeComponent();
this.playerImage = new Image();
}
public void CreateGrid(string ansFromServer, int numberOfRows, int numberOfCols, int type)
{
this.rows = numberOfRows;
this.cols = numberOfCols;
for (int i = 0; i < this.rows; i++)
{
RowDefinition def = new RowDefinition();
mainGrid.RowDefinitions.Add(def);
}
for (int i = 0; i < this.cols; i++)
{
ColumnDefinition def = new ColumnDefinition();
mainGrid.ColumnDefinitions.Add(def);
}
}
Grid.ColumnandGrid.Rowproperties of the Image to twointproperties in your view model, likeGrid.Column="{Binding GridColumn}". - Clemens