0
나는 다음과 같은 화면 및 모델 클래스에 바인딩 된 데이터 그리드,있어 : 어떤 이유로 또는 다른 들어왜 디스플레이가 무시됩니까?
public partial class AttributesWindow
{
public ObservableCollection<AttributesModel> ItemsSource { get; set; }
private readonly List<string> _fields = new List<string>(new[] { "Test1", "Test2" });
public ObservableCollection<AttributesModel> itemsSource { get; set; }
private DatabaseTable parentDatabaseTable = null;
public AttributesWindow(DatabaseTable parentDatabaseTable)
{
this.parentDatabaseTable = parentDatabaseTable;
InitializeComponent();
DataContext = this;
itemsSource = new ObservableCollection<AttributesModel>(_fields.Select(f => new AttributesModel(f)));
}
}
public class AttributesModel
{
public string Field { get; private set; }
[Display(Name = "Sort Order")]
public SortOrder SortBy { get; set; }
[Display(Name = "Group By")]
public string GroupBy { get; set; }
[Display(Name = "Having")]
public string Having { get; set; }
[Display(Name = "Display Order")]
public string DisplayOrder { get; set; }
[Display(Name = "Aggregate By")]
public Aggregate AggregateBy { get; set; }
public enum Aggregate
{
None,
Sum,
Minimum,
Maximum,
Average
}
public enum SortOrder
{
Unsorted,
Ascending,
Descending
}
public AttributesModel(string field)
{
Field = field;
}
}
을의 [Display(Name = "Sort Order")]
속성은 모두 무시하고, 내 데이터 그리드의 헤더에 복용 프로퍼티 명.
<DataGrid Name="dgAttributes"
ItemsSource="{Binding itemsSource}"
AutoGenerateColumns="True"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
ColumnWidth="Auto"
>
</DataGrid>
그리고이 이벤트의 본문에 무엇을 넣을까요? –
업데이트 된 답변보기 –
감사합니다. :) –