我正在尝试更改第3个/最后一列。
示例代码:
<Window x:Class="WpfTest2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:r="http://schemas.aspitalia.com/Ricciolo/Controls"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.Resources>
<XmlDataProvider x:Key="data" Source="Data.xml">
</XmlDataProvider>
<HierarchicalDataTemplate x:Key="dt" ItemsSource="{Binding XPath=outline}">
</HierarchicalDataTemplate>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<r:TreeView Name="Report" ItemsSource="{Binding Source={StaticResource data},XPath=/opml/body/outline/outline}" ItemTemplate="{StaticResource dt}">
<r:TreeView.Columns>
<GridViewColumn Header="Title" DisplayMemberBinding="{Binding XPath=@title}" Width="150" />
<GridViewColumn Header="Childs" DisplayMemberBinding="{Binding XPath=@count}" Width="100" />
<GridViewColumn Header="Url" DisplayMemberBinding="{Binding XPath=@xmlUrl}" Width="200" />
</r:TreeView.Columns>
</r:TreeView>
</Grid>
</Window>
答案 0 :(得分:1)
试试这个:
<r:TreeListView ItemsSource="{Binding Source={StaticResource data},XPath=/opml/body/outline/outline}" ItemTemplate="{StaticResource dt}">
<r:TreeListView.Columns>
<GridViewColumn Header="Title" DisplayMemberBinding="{Binding XPath=@title}" Width="150" />
<GridViewColumn Header="Childs" DisplayMemberBinding="{Binding XPath=@count}" Width="100" />
<GridViewColumn Header="Url" Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<Hyperlink NavigateUri="{Binding XPath=@xmlUrl}" RequestNavigate="Hyperlink_RequestNavigate">
<TextBlock Text="{Binding XPath=@xmlUrl}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</r:TreeListView.Columns>
</r:TreeListView>
在代码背后:
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
我在这里找到了解决方案:http://nishantrana.wordpress.com/2009/03/26/using-hyperlink-in-wpf-application/