<Grid x:Name="LayoutRoot" Background="White"> <CommonControl:NoapDataGrid MinHeight="120" Margin="10,0,10,10" HorizontalAlignment="Stretch" AutoGenerateColumns="False" ItemsSource="{Binding FtpFiles}" > <CommonControl:NoapDataGrid.Columns> <c1:DataGridTextColumn Header="文件名称" Binding="{Binding FileName}" /> <c1:DataGridTextColumn Header="文件类型" Binding="{Binding FileType}" /> <c1:DataGridTemplateColumn Header="操作"> <c1:DataGridTemplateColumn.CellTemplate> <DataTemplate> <HyperlinkButton Content="下载" Command="{Binding DataContext.DownloadFtpFileCommand, RelativeSource={RelativeSource AncestorLevel=2,AncestorType=Grid}}"/> </DataTemplate> </c1:DataGridTemplateColumn.CellTemplate> </c1:DataGridTemplateColumn> </CommonControl:NoapDataGrid.Columns> </CommonControl:NoapDataGrid> </Grid>
或者
<c1:DataGridTemplateColumn.CellTemplate> <DataTemplate> <HyperlinkButton Content="下载" Command="{Binding DataContext.DownloadFtpFileCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"/> </DataTemplate> </c1:DataGridTemplateColumn.CellTemplate>
时间: 2024-10-12 18:07:11