English 中文(简体)
数据Grid 中的超超链接不工作
原标题:Hyperlink in DataGrid is not working
  • 时间:2012-05-26 11:09:40
  •  标签:
  • c#
  • wpf

我正在写一个 WPF 应用程序, 在一个用户控制器中, 我在使用 DataGrid 中的超链接, 但它不起作用 。 我在使用 bing. com 来测试 。

<DataGrid Grid.Row="1" 
  AutoGenerateColumns="False" 
  Height="Auto" 
  Name="dataGrid1" 
  Width="Auto" 
  CanUserAddRows="False" 
  CanUserResizeColumns="True" 
  HorizontalAlignment="Stretch" 
  VerticalAlignment="Stretch" 
  Focusable="True" 
  IsHitTestVisible="False" 
  BorderThickness="0">
    <DataGrid.Columns >
        <DataGridTextColumn Header="Start Time" Width="*" Binding="{Binding Path=startTime}" CanUserSort="True"/>
        <DataGridTextColumn Header="End Time"   Width="*" Binding="{Binding Path=endTime}" CanUserSort="True"/>
        <DataGridTextColumn Header="Resources"  Width="*" Binding="{Binding Path=resources}" CanUserSort="True"/>
        <DataGridTextColumn Header="Action"  Width="*" Binding="{Binding Path=action}" CanUserSort="True"/>
        <DataGridTextColumn Header="Result"  Width="*" Binding="{Binding Path=result}" CanUserSort="True"/>
        <DataGridTemplateColumn Header="Health"  Width="*" CanUserSort="True">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock >
                        <Hyperlink NavigateUri="http://www.bing.com" RequestNavigate="Hyperlink_RequestNavigate"><!--"{Binding Path=healthUri}">-->
                            <TextBlock Text="{Binding Path=healthUri}" Focusable="True" />                                                                                    
                        </Hyperlink>                                    
                    </TextBlock>
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>
最佳回答

来自 MSDN 的 MSDN :

只有在超链接的直接或间接母体是导航主机,包括导航窗口、框架或任何浏览器(包括因特网探索者7、微软因特网探索者6和Firefox2.0+)能够主办XBAP的浏览器时,才能进行超链接导航。

你可以做到:

<Hyperlink NavigateUri="http://www.bing.com" RequestNavigate="Hyperlink_RequestNavigate">

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
    Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
    e.Handled = true;
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签