• WPF DataGridHyperlinkColumn


    为了点击链接,我们使用

                        <DataGrid x:Name="data" LoadingRow="load"  ItemsSource="{Binding Path=pull_gmc,Mode=TwoWay}" CanUserDeleteRows="True" AutoGenerateColumns="False" CanUserSortColumns="True">
                            <DataGrid.Columns >                            
                                <DataGridHyperlinkColumn Header="产品链接" ContentBinding="{Binding Path=prond}" Binding="{Binding Path=productId}">
                                    <DataGridHyperlinkColumn.ElementStyle>
                                        <Style TargetType="TextBlock">
                                            <EventSetter Event="Hyperlink.Click" HandledEventsToo="False" Handler="url"></EventSetter>
                                            <!--<EventSetter Event="MouseLeftButtonDown" Handler="url"></EventSetter>-->
                                        </Style>
                                    </DataGridHyperlinkColumn.ElementStyle>
                                </DataGridHyperlinkColumn>
                            </DataGrid.Columns>
                        </DataGrid>
        public class gmccolleague
        {
            public gmccolleague()
            {
            }
    
            /// <summary>
            /// 产品链接
            /// </summary>
            public string productId
            {
                set;
                get;
            }
    
            public static string prond
            {
                set;
                get;
            } = "产品链接";
    
            public int total
            {
                set;
                get;
            }
    
            /// <summary>
            /// 关键字
            /// </summary>
            public string primary
            {
                set;
                get;
            }
    
            /// <summary>
            /// 标题
            /// </summary>
            public string title
            {
                set;
                get;
            }
    
            /// <summary>
            /// 产品类别
            /// </summary>
            public string leaf_cat_name
            {
                set;
                get;
            }
    
            /// <summary>
            /// 使用次数
            /// </summary>
            public int count
            {
                set;
                get;
            }
    
            /// <summary>
            /// 质量得分
            /// </summary>
            public string iq_score
            {
                set;
                get;
            }
        }
    
            public ObservableCollection<gmccolleague> pull_gmc
            {
                set;
                get;
            } = new ObservableCollection<gmccolleague>();
    
    
            private void url(object sender, RoutedEventArgs e)
            {
                try
                {
                    Uri destination = ((Hyperlink)e.OriginalSource).NavigateUri;
                    Process.Start("http://" + destination.ToString());
                }
                catch 
                {
    
                }
            }
  • 相关阅读:
    CruiseControl.NET 三言两语
    在MFC程序中增加控制台
    VS2005 编译Release版本出现清单文件的错误
    内存泄露问题
    软件设计原则
    boost::shared_ptr 分析与实现
    corelDraw 的CDR格式解析
    13. 量词操作符—【LINQ标准查询操作符】
    SQL SERVER执行查询的顺序
    CSLA命令对象的简单封装
  • 原文地址:https://www.cnblogs.com/lindexi/p/12087592.html
Copyright © 2020-2023  润新知