我有一个DataGridWPF.而且我试图将Buttons 添加到网格的某些单元格中,然后绑定到特定的单元格ItemsSource.我试图在xaml中这样做:
<dg:DataGridTemplateColumn x:Name="R1" CanUserReorder="False" IsReadOnly="False">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<awc:ImageButton Content="Edit" Name="btnEdit" Visibility="Collapsed"/>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)
但是,我想知道如何在后面的代码中执行此操作.我需要这个,以便Button每当特定点击发生时我都可以放置.任何帮助将受到高度赞赏.
我在C#中制作一个WPF应用程序,我需要显示最近的文档历史记录(就像它发生在word,excel甚至visual studio中),显示列表中打开的最后5或10个文档.我完全不知道应该怎么做.请帮忙.请善良温和......我是一名资深人士,现在很难消化高科技会谈!:)
我试图从数据库填充数据网格(或gridview)作为树视图的子元素.我能够从树中的数据库中获取数据,但是,它似乎不适用于数据网格.这是我的xaml代码:
<Window x:Class="AttemptUsingHirarchichalData.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:AttemptUsingHirarchichalData"
xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<HierarchicalDataTemplate DataType="{x:Type data:Root}"
ItemsSource="{Binding Path=RootList}">
<TextBlock Text="{Binding RootNode}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type data:Nodes}"
ItemsSource="{Binding Path=ChildList}">
<TextBlock Text="{Binding ChildNode}"/>
</HierarchicalDataTemplate>
</Window.Resources>
<Grid>
<TreeView Name="TreeView1">
<TreeViewItem ItemsSource="{Binding Path=RootList}"
Header="{Binding RootNode}"/>
<TreeViewItem ItemsSource="{Binding Path=dt_Age}"
Header="{Binding dt_Age}"/>
</TreeView>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我的代码隐藏是这样的:
InitializeComponent();
Root obj_Root = new Root();
obj_Root.RootNode = "RootNode";
obj_Root.RootList = new List<Nodes>();
Class1 obj_Class1 = new Class1();
DataTable dt_Age = obj_Class1.GetAgeInComboBox();
for (int i = 0; i < dt_Age.Rows.Count; i++)
{
Nodes obj_AgeNode …Run Code Online (Sandbox Code Playgroud)