0
我正在使用PRISM和MEF框架。 我有一個數據網格,它顯示了一些數據,並且它下面有RowDetailsTemplate,它又有數據網格。現在,如果我嘗試從RowDetailsTemplate下的datagrid中刪除一行,那麼在刪除操作之後UI將不會刷新。換句話說,該行被刪除,但剩下一個空白空間,並且當前行下方的行不會向上移動。刪除行後DataGrid不會刷新
下面是代碼片段。
<Controls1:DataGrid x:Name="dgProposals"
Grid.Row="1" ItemsSource="{Binding Items}" AutoGenerateColumns="False"
BorderThickness="0"
CanUserResizeColumns="False" RowDetailsVisibilityMode="Visible">
<Controls1:DataGrid.Columns>
<Controls1:DataGridTextColumn Binding="{Binding ProposalName}" Width="*"
CanUserSort="False" IsReadOnly="True" CanUserReorder="False" >
</Controls1:DataGridTextColumn>
<Controls1:DataGridTextColumn Binding="{Binding DisplayProposalType}"
Width="*" CanUserSort="False" IsReadOnly="True" CanUserReorder="False" >
</Controls1:DataGridTextColumn>
</Controls1:DataGrid.Columns>
<Controls1:DataGrid.RowDetailsTemplate >
<DataTemplate>
<Controls1:DataGrid x:Name="dgReports" ItemsSource="{Binding ReportList}"
AutoGenerateColumns="False" BorderThickness="0"
CanUserResizeColumns="False" HeadersVisibility="None">
<Controls1:DataGrid.Columns>
<Controls1:DataGridTextColumn Binding="{Binding Name}" Width="*"
CanUserSort="False" IsReadOnly="True" CanUserReorder="False" >
</Controls1:DataGridTextColumn>
<Controls1:DataGridTemplateColumn Width="100" CanUserSort="False"
CanUserReorder="False">
<Controls1:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button VerticalAlignment="Center" Cursor="Hand"
Command="{Binding DataSource.EditReportNameCommand,
Source={StaticResource DataContextProxy}}"
CommandParameter="{Binding}" Margin="5,0">
</Button>
</StackPanel>
</DataTemplate>
</Controls1:DataGridTemplateColumn.CellTemplate>
</Controls1:DataGridTemplateColumn>
</Controls1:DataGrid.Columns>
</Controls1:DataGrid>
</DataTemplate>
</Controls1:DataGrid.RowDetailsTemplate>
BO代碼片斷如下:
public class ProposalPreview : NotificationObject
{
public string ProposalName { get; set; }
public int PartyId { get; set; }
public string PartyName { get; set; }
public string DisplayProposalType { get; set; }
private ObservableCollection<ArchievedReport> reportList = null;
public ObservableCollection<ArchievedReport> ReportList
{
get { return reportList; }
set { reportList = value; }
}
public ProposalPreview()
{
ProposalName = "";
DisplayProposalType = String.Empty;
ReportList = new ObservableCollection<ArchievedReport>();
}
}
public class ArchievedReport : NotificationObject
{
private string name;
public string Name
{
get { return name; }
set
{
name = value;
RaisePropertyChanged("Name");
}
}
public int ReportId { get; set; }
}
這裏項目是的ObservableCollection。
希望我對我的描述很清楚。 請讓我知道你是否需要更多信息。 任何幫助,不勝感激。 非常感謝您的時間。
謝謝,
Maddy。
我正在使用MVVM模式,我不知道如何重新綁定ViewModel的數據源。你能詳細說明你的答案嗎? – user1181458 2012-02-01 00:02:43