[英]Extended WPF Toolkit Datagrid with binding
Sorry but I only found the way with the FieldName defined in the column tag or the old style 抱歉,但我只找到了在column标签或旧样式中定义的FieldName的方法
<xcdg:DataGridCollectionViewSource x:Key="cvsMetals" Source="{Binding MetalTypes}">
<xcdg:DataGridCollectionViewSource.GroupDescriptions>
<!--<PropertyGroupDescription PropertyName="Year" />-->
</xcdg:DataGridCollectionViewSource.GroupDescriptions>
</xcdg:DataGridCollectionViewSource>
<xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource cvsMetals} }" AutoCreateColumns="True">
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="Name" IsMainColumn="True"></xcdg:Column>
<xcdg:Column FieldName="Year"></xcdg:Column>
<xcdg:Column FieldName="SelectedMetalSeries.Name"></xcdg:Column>
</xcdg:DataGridControl.Columns>
</xcdg:DataGridControl>
The last column with SelectedMetalSeries.Name is a class with properties. SelectedMetalSeries.Name的最后一列是带有属性的类。 I didn't find a way to show this property name of the object
我没有找到显示对象此属性名称的方法
My ViewModels: 我的ViewModels:
public class AllMetalTypeViewModel : WorkspaceViewModel
{
private ObservableCollection<MetalTypeViewModel> _metalTypes;
public ObservableCollection<MetalTypeViewModel> MetalTypes
{
get { return _metalTypes; }
set { Set("MetalTypes", ref _metalTypes, value); }
}
public class MetalTypeViewModel: WorkspaceViewModel
{
private MetalSeries _selectedMetalSeries;
public MetalSeries SelectedMetalSeries
{
get { return _selectedMetalSeries; }
set { Set("SelectedMetalSeries", ref _selectedMetalSeries, value); }
}
private short _year;
public short Year
{
get { return _year; }
set { Set("Year", ref _year, value); }
}
private string _name;
public string Name
{
get { return _name; }
set { Set("Name", ref _name, value); }
}
public partial class MetalSeries
{
#region Primitive Properties
public virtual long ID
{
get;
set;
}
public virtual string Name
{
get;
set;
}
I found the old style which seems no longer to work with the new version: 我发现旧样式似乎不再适用于新版本:
<ExtendedColumn:ExtendedDataGridTextColumn Header="Publisher" Binding="{Binding Publisher}" AllowAutoFilter="False" CanUserSort="False" Width="*"/>
The problem is that I can't find a property where I can bind my ViewModel properties 问题是我找不到可以绑定ViewModel属性的属性
It is a FieldName not Binding and as I see it does not support nesting. 这是一个不绑定的FieldName,并且我看到它不支持嵌套。 However a "good" design should not have such issues.
但是,“好的”设计不应有此类问题。 I would try simply creating a dedicated ViewModel for the DataGrid.
我将尝试为DataGrid创建一个专用的ViewModel。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.