为什么我无法绑定 datagrid 属性选定项?我的 ViewModel 中有财产
protected TheFile curentFile ;
public TheFile CurentFile
{
get { return curentFile; }
set { curentFile = value;
OnPropertyChanged("CurentFile"); }
}
这是我的数据网格:
<DataGrid IsReadOnly="True" AutoGenerateColumns="False" Grid.ColumnSpan="1" Grid.Row="1" Grid.Column="0" Grid.RowSpan="1" Name="dataGrid1" ItemsSource="{Binding SameFileGroups}" SelectedItem="{Binding CurentGroup}">
<DataGrid.Columns>
<DataGridTextColumn Header="Всього" Width="1*" Binding="{Binding TotalSizeInDirectory}"/>
<DataGridTextColumn Header="1 файл" Width="1*" Binding="{Binding OneFileSize}"/>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid ItemsSource="{Binding Path=Files}" AutoGenerateColumns="False" SelectedItem="{Binding Path=CurentFile, UpdateSourceTrigger=PropertyChanged}">
<DataGrid.Columns>
<DataGridTextColumn Header="Шлях" Binding="{Binding Path=Destination}"/>
<DataGridTextColumn Header="Розмір" Binding="{Binding Path=SizeBytes}"/>
<DataGridTextColumn Header="md5" Binding="{Binding Path=Md5Hash}"/>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
但是这个绑定不起作用
<DataGrid ItemsSource="{Binding Path=Files}" AutoGenerateColumns="False" SelectedItem="{Binding Path=CurentFile, UpdateSourceTrigger=PropertyChanged}">