【发布时间】:2017-07-30 23:14:49
【问题描述】:
我的以下代码存在性能问题。我正在尝试将两个列表与两个 DataGrid 绑定。每个列表的 DataGrid。我需要一个双向绑定。有谁知道为什么?或者有什么建议?
这是我的课
public class Vertices
{
public int ID { get; set; }
public double PositionX { get; set; }
public double PositionY { get; set; }
public string Description { get; set; }
public bool IsMap { get; set; }
public bool IsStartEndPoint { get; set; }
public bool IsDisplay { get; set; }
public bool IsExit { get; set; }
public string TextToSpeech { get; set; }
}
public class Edges
{
public int ID { get; set; }
public int SourceVertex { get; set; }
public int TargetVertex { get; set; }
public bool IsNormal { get; set; }
public bool IsElevatorUp { get; set; }
public bool IsElevatorDown { get; set; }
public bool IsStairUp { get; set; }
public bool IsStairDown { get; set; }
}
这是我的 XAML 代码
<DataGrid x:Name="DataGridVertices" Grid.Row="1" Grid.Column="3" BorderBrush="AliceBlue" BorderThickness="5" AutoGenerateColumns="True" ItemsSource="{Binding AllVerticesList}" />
<DataGrid x:Name="DataGridEdges" Grid.Row="2" Grid.Column="3" BorderBrush="AliceBlue" BorderThickness="5" AutoGenerateColumns="True" ItemsSource="{Binding AllEdgesList}" />
这是我的代码隐藏
this.DataGridVertices.ItemsSource = AllVerticesList;
this.DataGridEdges.ItemsSource = AllEdgesList;
我正在使用 DataGrid.Items.Refresh() 更新 DataGrid;
谢谢!
【问题讨论】: