I'm trying to set the ItemsSource
property of a DataGrid
named dgIssueSummary
to be an ObservableCollection
named IssueSummaryList
. Currently, everything is working when I set the ItemsSource
property in my code-behind:
public partial class MainPage : UserControl
{
private ObservableCollection<IssueSummary> IssueSummaryList = new ObservableCollection<IssueSummary>
public MainPage()
{
InitializeComponent();
dgIssueSummary.ItemsSource = IssueSummaryList
}
}
However, I'd rather set the ItemsSource
property in XAML, but I can't get it to work. Here's the XAML code I have:
<sdk:DataGrid x:Name="dgIssueSummary" AutoGenerateColumns="False"
ItemsSource="{Binding IssueSummaryList}" >
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Binding="{Binding ProblemType}" Header="Problem Type"/>
<sdk:DataGridTextColumn Binding="{Binding Count}" Header="Count"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
What do I need to do to set the ItemsSource
property to be the IssueSummaryList
in XAML rather than C#?