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>

 

posted @ 2014-09-23 10:21  akiing  阅读(352)  评论(0编辑  收藏  举报