wpf 中 datagrid 有一个模板列 显示的是数字 我希望点击这个数字 弹出一个窗口 xmal里面改怎么写?
我用的是button按钮可以实现但太难看了linkbutton用不了希望高薪贴代码非常感谢...
我用的是button按钮 可以实现 但太难看了 linkbutton 用不了 希望高薪贴代码 非常感谢
展开
1个回答
展开全部
xaml
<DataGrid Grid.Row="6" Name="dg" AutoGenerateColumns="False" Hyperlink.Click="DataGridHyperlinkColumn_Click">
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="点击链接" Binding="{Binding Title}" ></DataGridHyperlinkColumn>
</DataGrid.Columns>
</DataGrid>
private void DataGridHyperlinkColumn_Click(object sender, RoutedEventArgs e)
{
var dg = sender as DataGrid;
var row = dg.SelectedItem as Pages;
if(row !=null)
row.WindowEnty.Show();
}
pages辅助类:
public class Pages
{
public Window WindowEnty { get; set; }
public int Title { get; set; }
}
定义datagrid的source:
var demo = new WDemo();
var list2 = new List<Pages> { new Pages { WindowEnty = demo, Title = 1 } };
dg.ItemsSource = list2;
<DataGrid Grid.Row="6" Name="dg" AutoGenerateColumns="False" Hyperlink.Click="DataGridHyperlinkColumn_Click">
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="点击链接" Binding="{Binding Title}" ></DataGridHyperlinkColumn>
</DataGrid.Columns>
</DataGrid>
private void DataGridHyperlinkColumn_Click(object sender, RoutedEventArgs e)
{
var dg = sender as DataGrid;
var row = dg.SelectedItem as Pages;
if(row !=null)
row.WindowEnty.Show();
}
pages辅助类:
public class Pages
{
public Window WindowEnty { get; set; }
public int Title { get; set; }
}
定义datagrid的source:
var demo = new WDemo();
var list2 = new List<Pages> { new Pages { WindowEnty = demo, Title = 1 } };
dg.ItemsSource = list2;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询