2

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; }
}
4

1 に答える 1

8

HorizontalContentAlignmentプロパティをに設定してみましたかStretch

于 2012-04-17T09:46:17.210 に答える