在我的WPF应用程序中,我有一个包含DataGrid的窗口(全部代码)。这是我的DataGrid绑定:
using (var db = new CompanyEntities())
{
var stocks = db.Stock;
var query = from s in stocks
select new { s.Id_Product, s.Quantity };
dataGrid.ItemsSource = query.ToList();
}
我想读取在DataGrid中选择的单元格。我试着用DataGrid.SelectedIt
在我的WPF应用程序中,我想通过向某些属性添加可浏览(False)的方法,在DataGrid中隐藏带有绑定ItemsSource的列,但是,不管有没有可浏览(False),所有列都是可见的。
我的模特:
public class Room : INotifyPropertyChanged
{
private int id;
...
[Browsable(false)]
public int Id
{
get
{
return this.id;
}
set
我有一个
ObservableCollection<CustomObj> DataInfo
在我的MVVM WPF项目中。CustomObj类如下所示:
public class class1 : ObservableObject
{
public class1()
{
MySecondProperty = new Class2();
}
public string MyStringValue { get; set; }
public Class2 MySecondProperty { get; set; }
pu
我有一个在单元级别使用以下类型填充的DataTable:
public class GridCell
{
public string Value { get; set}
public Guid Id { get; set; }
}
我已经将DataTable绑定到WPF Toolkit DataGrid,但是单元格是空的。如何告诉DataGrid在GridCell类型的Value属性中查找单元格内容?
绑定代码片段:
<DataGrid ItemsSource="{Binding SelectedItem.Table}" />
我有一个WPF DataGrid,当我通过一个集合添加一个新项时,我在MVVM中使用C#选择那个新项(行)。
// Adding the new item (which will create a new row)
ItemSourceCollection.Add(object);
// The itemSource would have refreshed, so now assign the SelectedItem of the grid
SelectedItem = ItemSourceCollection.Where(x => x.Id == Id).FirstOrDefau