I've set the HorizontalAlignment property to stretch but it did not help.
I need that content control since in my real code the DataGrid is injected with prism into the content control.
XAML:
<ContentControl HorizontalAlignment="Stretch">
<Grid>
<Controls:DataGrid ItemsSource="{Binding Persons}"></Controls:DataGrid>
</Grid>
</ContentControl>
Code behind:
public partial class MainPage : UserControl
{
public List<Person> Persons { get; set; }
public MainPage()
{
Persons = new List<Person>();
Persons.Add(new Person { Name = "A",Age = 5});
Persons.Add(new Person { Name = "A", Age = 5 });
Persons.Add(new Person { Name = "A", Age = 5 });
InitializeComponent();
DataContext = this;
}
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}