WPF中使用DataGrid,用DataGridHyperlinkColumn定义的列其跳转怎么实现?
如图,每一列的数据都绑定到数据库的;要实现点击每一行的标题跳转至其他的窗口,标题列定义为<DataGridHyperlinkColumnHeader="标题"Bindin...
如图,每一列的数据都绑定到数据库的;要实现点击每一行的标题跳转至其他的窗口,标题列定义为 <DataGridHyperlinkColumn Header="标题" Binding="{Binding Path=Title}"/>,要做何修改吗?
展开
展开全部
xaml:
<DataGrid Grid.Row="6" Name="dg" AutoGenerateColumns="False" Hyperlink.Click="DataGridHyperlinkColumn_Click">
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="点击链接" Binding="{Binding Title}" ></DataGridHyperlinkColumn>
</DataGrid.Columns>
</DataGrid>
绑定的数据源为:
var list2 = new List<Pages> { new Pages { WindowEnty = demo, Title = demo.Title } };
dg.ItemsSource = list2;
pages的定义:
public class Pages
{
public Window WindowEnty { get; set; }
public string Title { get; set; }
}
private void DataGridHyperlinkColumn_Click(object sender, RoutedEventArgs e)
{
var dg = sender as DataGrid;
var row = dg.SelectedItem as Pages;
row.WindowEnty.Show();
}
<DataGrid Grid.Row="6" Name="dg" AutoGenerateColumns="False" Hyperlink.Click="DataGridHyperlinkColumn_Click">
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="点击链接" Binding="{Binding Title}" ></DataGridHyperlinkColumn>
</DataGrid.Columns>
</DataGrid>
绑定的数据源为:
var list2 = new List<Pages> { new Pages { WindowEnty = demo, Title = demo.Title } };
dg.ItemsSource = list2;
pages的定义:
public class Pages
{
public Window WindowEnty { get; set; }
public string Title { get; set; }
}
private void DataGridHyperlinkColumn_Click(object sender, RoutedEventArgs e)
{
var dg = sender as DataGrid;
var row = dg.SelectedItem as Pages;
row.WindowEnty.Show();
}
来自:求助得到的回答
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询