datagridtemplatecolumn

WPF - How to bind a DataGridTemplateColumn

血红的双手。 提交于 2019-12-03 11:19:31
问题 I am trying to get the name of the property associated with a particular DataGridColumn , so that I can then do some stuff based on that. This function is called when the user clicks context menu item on the column's header... This is fine for the out-of-the-box ready-rolled column types like DataGridTextColumn , since they are bound, but the problem is that some of my columns are DataGridTemplateColumns , which are not bound. private void GroupByField_Click (object sender, RoutedEventArgs e)

WPF DataGrid how to set ColumnType to different type based on bound data?

丶灬走出姿态 提交于 2019-12-03 07:48:39
问题 I have "Preferences" data structure where I have string "Value" field and enum for "Type" field. Type can be 0-Boolean, 1-Integer, 2-String ... Depending on value in this Type field I'd like to display "Value" cell different way Checkbox, Textbox, dropdown, etc. So, to make it clear - same column should display different cells depending on data in that row.. I guess I need to employ DataGridTemplateColumn but I never did that and would like some example if possible. Also, what can I do with

DataGridTemplateColumn Two way binding is not working

妖精的绣舞 提交于 2019-12-03 00:41:12
I've got a datagrid I've bound to a SqlDataApter. If I set up the XAML for the grid using DataTextColumn as illustrated in the code below it works perfectly <DataGrid AutoGenerateColumns="False" HorizontalAlignment="Left" Margin="27,42,0,0" Name="dataGrid1" VerticalAlignment="Top" AreRowDetailsFrozen="True"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding KEY}" Visibility="Hidden" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Binding="{Binding CHARACTERISTIC_CODE}" Header="Unit" IsReadOnly="True" /> <DataGridTextColumn Binding="{Binding UNIT_CHAR}" Header="Unit"

WPF DataGrid how to set ColumnType to different type based on bound data?

那年仲夏 提交于 2019-12-02 21:16:07
I have "Preferences" data structure where I have string "Value" field and enum for "Type" field. Type can be 0-Boolean, 1-Integer, 2-String ... Depending on value in this Type field I'd like to display "Value" cell different way Checkbox, Textbox, dropdown, etc. So, to make it clear - same column should display different cells depending on data in that row.. I guess I need to employ DataGridTemplateColumn but I never did that and would like some example if possible. Also, what can I do with XAML and what needs to be done in Code? I guess Value converter will have to be used as well? <DataGrid

Pass whole row as parameter of DataGridTemplateColumn Hyperlink

岁酱吖の 提交于 2019-12-02 04:43:17
问题 Is it possible to pass a whole row as a parameter for the Hyperlink of DataGridTemplateColumn? <my:DataGridTemplateColumn Header="Name"> <my:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock> <Hyperlink Foreground="Black" TextDecorations="None"> <Run Text="{Binding Name}" /> </Hyperlink> </TextBlock> </DataTemplate> </my:DataGridTemplateColumn.CellTemplate> </my:DataGridTemplateColumn> 回答1: Hard to tell what you are trying to achieve but a ComandParameter binding without a value

Pass whole row as parameter of DataGridTemplateColumn Hyperlink

白昼怎懂夜的黑 提交于 2019-12-01 22:52:20
Is it possible to pass a whole row as a parameter for the Hyperlink of DataGridTemplateColumn? <my:DataGridTemplateColumn Header="Name"> <my:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock> <Hyperlink Foreground="Black" TextDecorations="None"> <Run Text="{Binding Name}" /> </Hyperlink> </TextBlock> </DataTemplate> </my:DataGridTemplateColumn.CellTemplate> </my:DataGridTemplateColumn> Hard to tell what you are trying to achieve but a ComandParameter binding without a value should give you the row eg <Hyperlink Foreground="Black" TextDecorations="None" CommandParameter="{Binding}"

Bind DataGridTemplateColumn Visibility

和自甴很熟 提交于 2019-12-01 07:40:37
问题 I am trying to bind the visibility of a column in a datagrid to a boolean DependencyProperty in the ViewModel (Set as data context of the View - UserControl in this case). For some reason (I don't seem to understand) it just doesn't work. After looking here I found out that the datagridtemplate (and any other template) is not part of the visual tree. So I can't bind to it. Any simple solution to the problem (without breaking the MVVM pattern of course) ? 回答1: Found the solution here: http:/

WPF DataGridTemplateColumn shared template?

我们两清 提交于 2019-12-01 05:13:01
Hi I have a datagrid that has a number of datagridtemplate columns that are all identical apart from they each have a different datacontext on the template's stackpanel. <toolkit:DataGridTemplateColumn Header="Col 1"> <toolkit:DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel DataContext="{Binding Times[0]}"> <!-- the structure that I want to extract to a template --> </StackPanel> </DataTemplate> </toolkit:DataGridTemplateColumn.CellTemplate> </toolkit:DataGridTemplateColumn> <toolkit:DataGridTemplateColumn Header="Col 2"> <toolkit:DataGridTemplateColumn.CellTemplate>

WPF DataGridTemplateColumn shared template?

对着背影说爱祢 提交于 2019-12-01 02:10:53
问题 Hi I have a datagrid that has a number of datagridtemplate columns that are all identical apart from they each have a different datacontext on the template's stackpanel. <toolkit:DataGridTemplateColumn Header="Col 1"> <toolkit:DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel DataContext="{Binding Times[0]}"> <!-- the structure that I want to extract to a template --> </StackPanel> </DataTemplate> </toolkit:DataGridTemplateColumn.CellTemplate> </toolkit:DataGridTemplateColumn>

DataGridTemplateColumn with DatePicker requires three clicks to edit the date

假装没事ソ 提交于 2019-11-30 21:50:27
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. biju You have to override the PrepareCellForEdit in DataGridTemplateColumn as follows: public class DataGridDateColumn:DataGridTemplateColumn { protected override object