수평

2012-04-17 3 views
2

나는 스트레칭하는 HorizontalAlignment로 속성을 설정했지만 그것은 도움이되지 않았다. 내 진짜 코드에서 데이터 그리드가 콘텐츠 컨트롤에 프리즘 주입되기 때문에수평

는 그 콘텐츠 컨트롤이 필요합니다.

XAML :

<ContentControl HorizontalAlignment="Stretch"> 
    <Grid> 
     <Controls:DataGrid ItemsSource="{Binding Persons}"></Controls:DataGrid> 
    </Grid> 
</ContentControl> 

코드 숨김

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

답변

8

당신이 Stretch

HorizontalContentAlignment 속성을 설정하려고 되세요