0

basically i want to bind a specific row to a grid in the .cs files is it possible ??

Here is the schematics

<Grid x:Name="grid1">
<Grid.RowDefinition>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /><!-- want to bind this row to a grid made in c# -->
<RowDefinition Height="Auto" />
</Grid.RowDefinition>

</Grid>
5
  • the code here creates 3 rows of equal size. What you want to do exactly? Commented Apr 4, 2016 at 7:52
  • the second row i want to bid it to a grid C# made . this grid contains a stack layout witch component are created dynamically from a db Commented Apr 4, 2016 at 7:54
  • couldnt understand your requirement though but a grid row can have your stack panel.....something like this... on your stackpanel add this Grid.Row="1" so that the stack panel moves into the second row Commented Apr 4, 2016 at 7:57
  • yes in the xaml file but can i do the same in the c# file specify the row in the c# . something like Commented Apr 4, 2016 at 7:58
  • yeah you can do that ! check the answer below Commented Apr 4, 2016 at 7:58

1 Answer 1

1
//Create an object of your stackPanel programatically. Make sure your stackpanel //has a name
StackPanel MyStackPanel = new StackPanel ();
StackPanel .Name= "stackPanel1";

Grid.SetRow(MyStackPanel , 1); 
Grid.SetColumn(MyStackPanel , 0);  // for setting it to 1st column
grid1.Children.Add(MyStackPanel );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.