silverlight wpf DataTemplate Command binding
<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>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。