I'm trying to use Listview. First i used it to have my items in a column align, it worked
Now I'm trying to search a solution to have not align my items in column.
For this I have a grid with 8 rows and 8 columns.
I want the first item in :
Grid.Row="1" Grid.Column ="1"
I want the second item in :
Grid.Row="3" Grid.Column ="3"
I want the third item in :
Grid.Row="6" Grid.Column ="3"
I want the fourth item in :
Grid.Row="8" Grid.Column ="1"
Do you think it's possible ? do you have any idea? I did ever read ItemView and listview documentation but i didn't find anything about grid position.
King Regards
You need customize the Grid .
public class MyGird: Grid
{
Label first;
Label second;
Label third;
Label fourth;
public MyGird()
{
this.BindingContextChanged += MyGird_BindingContextChanged;
for(int i = 0; i < 8; i++)
{
RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
}
for (int i = 0; i < 8; i++)
{
ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
}
first = new Label { };
second = new Label { };
third = new Label { };
fourth = new Label { };
Children.Add(first, 0, 0);
Children.Add(second, 2, 2);
Children.Add(third, 5, 2);
Children.Add(fourth, 7, 0);
}
private void MyGird_BindingContextChanged(object sender, EventArgs e)
{
var grid = sender as Grid;
var obj = grid.BindingContext as List<string>;
first.Text = obj[0];
second.Text = obj[1];
third.Text = obj[2];
fourth.Text = obj[3];
}
}
public List<string> list { get; set; }
public Page2()
{
InitializeComponent();
list = new List<string> { "1", "2", "3", "4" };
this.BindingContext = this;
}
<local:MyGird BindingContext="{Binding list}"/>