datagridtemplatecolumn

DataGridTemplateColumn with DatePicker requires three clicks to edit the date

[亡魂溺海] 提交于 2019-11-30 17:16:38
问题 I have a DataGridTemplateColumn . Inside its CellEditingTemplate , I put a DatePicker control. Now if I want to edit the date, I have to click three times to let DatePicker begin editing. Can someone let me know how I can get DatePicker into edit mode with only two clicks? Also, if DataGridTemplateColumn get focused, keyboard typing doesn't put DatePicker into edit mode as well. It would be nice if it can be fixed as well. 回答1: You have to override the PrepareCellForEdit in

Editable DataGrid - CanUserAddRows=“True” not working

六月ゝ 毕业季﹏ 提交于 2019-11-29 12:03:54
I have the following DataGrid: <DataGrid ItemsSource="{Binding EmployeeList}" CanUserAddRows="True" AutoGenerateColumns="False" Margin="0,0,0,90"> <DataGrid.Columns> <DataGridTemplateColumn Header="CountryCombo2"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding Path=DataContext.CountryList, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" DisplayMemberPath="CountryName" SelectedItem="{Binding EmployeeCountry, Mode=TwoWay}" SelectedValue="{Binding EmployeeCountry.CountryId}" SelectedValuePath="CountryId" /> </DataTemplate> <

Add a Image in the DataGridTemplateColumn

偶尔善良 提交于 2019-11-29 04:55:40
BitmapImage im = new BitmapImage(); string path1 = @"C:\abc.png"; im.UriSource=new Uri(path1); DataGridTemplateColumn one = new DataGridTemplateColumn(); this.dataGrid1.Columns.Add(one); Now i have to add the BitmapImage im in the datagridTemplateColumn. How to add Image in the column?? Working with control templates in code is hard. In WPF the standard and effective way is to create your template layout in XAML. And then if you need to pass any data to your controls you use Data Binding. You shouldn't normally need to construct templates in code except for rare circumstances. To get the same

DataGridTemplateColumn : Items collection must be empty before using ItemsSource.

我是研究僧i 提交于 2019-11-28 11:58:34
Why is the error code : <dg:DataGrid Name="dataGrid" AutoGenerateColumns="False" HeadersVisibility="Column" SelectedIndex="-1" Margin="0,315,0,0" Background="#FF484040" BorderBrush="#FF484040"> <dg:DataGrid.Columns> <dg:DataGridTextColumn Binding="{Binding IdBook}" Header="IdBook"></dg:DataGridTextColumn> <dg:DataGridTextColumn Binding="{Binding NameBook}" Header="NameBook"></dg:DataGridTextColumn> <dg:DataGridTextColumn Binding="{Binding Author}" Header="Author"></dg:DataGridTextColumn> </dg:DataGrid.Columns> <dg:DataGridTemplateColumn Header="Delete"> <dg:DataGridTemplateColumn.CellTemplate>

WPF Datagrid -DataGridTemplateColumn tab focus issue

扶醉桌前 提交于 2019-11-28 09:47:14
I am using Microsoft WPF datagrid. I have noticed a strange behavior with WPF datagrid DataGridTemplateColumn. When you use the templateColumn in the grid and the template column contains some controls when you tab from the previous column the focus is not automatically given to the first element declared in the template column. The foucs is initally set on the border of the template column and when we tab of once agin the focus goes to the first column. Any workaround for this issue. How can i set the focus to go the first element in the template column of the datagrid when i tab off. I got

WPF DataGridTemplateColumn with ComboBox Binding (MVVM pattern)

孤街浪徒 提交于 2019-11-28 09:14:32
I'm going bonkers with the following WPF DataGrid+ComboBox scenario. I have a set of classes which look like; class Owner { int ID { get; } string Name { get; } public override ToString() { return this.Name; } } class House { int ID { get; } Owner HouseOwner { get; set; } } class ViewModel { ObservableCollection<Owner> Owners; ObservableCollection<House> Houses } Now my desired outcome is a DataGrid which shows a list of rows of type House , and in one of the columns, is a ComboBox which allows the user to change the value of House.HouseOwner . In this scenario, the DataContext for the grid is

Editable DataGrid - CanUserAddRows=“True” not working

戏子无情 提交于 2019-11-28 05:37:51
问题 I have the following DataGrid: <DataGrid ItemsSource="{Binding EmployeeList}" CanUserAddRows="True" AutoGenerateColumns="False" Margin="0,0,0,90"> <DataGrid.Columns> <DataGridTemplateColumn Header="CountryCombo2"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding Path=DataContext.CountryList, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" DisplayMemberPath="CountryName" SelectedItem="{Binding EmployeeCountry, Mode=TwoWay}" SelectedValue="

Add a Image in the DataGridTemplateColumn

拥有回忆 提交于 2019-11-27 18:48:10
问题 BitmapImage im = new BitmapImage(); string path1 = @"C:\abc.png"; im.UriSource=new Uri(path1); DataGridTemplateColumn one = new DataGridTemplateColumn(); this.dataGrid1.Columns.Add(one); Now i have to add the BitmapImage im in the datagridTemplateColumn. How to add Image in the column?? 回答1: Working with control templates in code is hard. In WPF the standard and effective way is to create your template layout in XAML. And then if you need to pass any data to your controls you use Data Binding

What is the code behind for datagridtemplatecolumn, and how to use it?

断了今生、忘了曾经 提交于 2019-11-27 08:07:39
I have a DataGrid in WPF. And I am trying to add Button s to certain cells of the grid, after it is bound to a particular ItemsSource . I have tried to do this in the xaml like this: <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> However, I want to know as to how I can do this in the code behind. I need this so that I can place Button s whenever a

DataGridTemplateColumn : Items collection must be empty before using ItemsSource.

ぃ、小莉子 提交于 2019-11-27 06:39:14
问题 Why is the error code : <dg:DataGrid Name="dataGrid" AutoGenerateColumns="False" HeadersVisibility="Column" SelectedIndex="-1" Margin="0,315,0,0" Background="#FF484040" BorderBrush="#FF484040"> <dg:DataGrid.Columns> <dg:DataGridTextColumn Binding="{Binding IdBook}" Header="IdBook"></dg:DataGridTextColumn> <dg:DataGridTextColumn Binding="{Binding NameBook}" Header="NameBook"></dg:DataGridTextColumn> <dg:DataGridTextColumn Binding="{Binding Author}" Header="Author"></dg:DataGridTextColumn> </dg