• 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 
                {
    
                }
            }
  • 相关阅读:
    两年工作感想
    ASP常用的38个内置函数
    asp汉字转换成汉语拼音
    js高级表格排序
    使用XmlHttpRequest对象调用Web Services 服务
    75个最佳Web设计资源
    C# FTP操作类
    存储过程操作类
    Windows Mobile 5.0 SDK 下载地址
    链表C#实现
  • 原文地址:https://www.cnblogs.com/lindexi/p/12087593.html
Copyright © 2020-2023  润新知