datagridtemplatecolumn

Force DataTemplateCell with CellTemplateSelector in WPF DataGrid Autogenerated columns

戏子无情 提交于 2019-12-13 04:20:37
问题 I have a data grid to which I bind a DataTable. I don't know what rows or columns will be in the data table so I set the AutogenerateColumns property of the data grid to true. The only thing I do know for certain is that every cell in the data table will be of type Field and the Field class has a enum property called Type. <DataGrid x:Name="dg" AutoGenerateColumns="True" ItemsSource="{Binding Path=Fields}" AutoGeneratingColumn="dg_AutoGeneratingColumn"> </DataGrid> What I want to do is to

wpf set the content of datagrid's selected templatecolumn's textbox

▼魔方 西西 提交于 2019-12-12 18:00:47
问题 I need to find out how to pass a string to ComboBox that's inside of a TemplateColumn of a DataGrid . The idea behind is that whenever I double-click on a TextBox a Popup appears and I select the new content of the TextBox from it ( ComboBox inside a Popup ). XAML <DataGridTemplateColumn Header="unit"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding unit}" MouseDoubleClick="TextBox_MouseDoubleClick_1" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <

WPF contents of cell of DataGridTemplateColumn

∥☆過路亽.° 提交于 2019-12-12 02:00:59
问题 In WPF I have the reference to a DataGridCell and would like to get its contents. I used to have that cell in a DataGridTextColumn and could get at the content like this: var text = cell.Content as TextBlock; But this is not longer working since the cell is in a DataGridTemplateColumn, although I did specify TextBlock as the DataTemplate for that column. Is there still a way to get at it? EDIT to clarify the problem. The following code is working as intended: <!-- XAML --> <DataGridTextColumn

DataGridTemplateColumn InvokeCommandAction Template

孤人 提交于 2019-12-12 01:46:21
问题 I'm using a UserControl where the main control inside is a datagrid. All is working. However, some lines of my code are redundant since I implement the same trigger in each of the 48 columns. How do I make a template for the datagridtemplatecolumn of the following code snippet? The only thing different in each column is the bound property. All the triggers and formatting are the same. I would appreciate your help! <DataGridTemplateColumn Header="5" MaxWidth="10"> <DataGridTemplateColumn

How can I know the checked/unckecked status of the checkboxes on the grid?

孤街浪徒 提交于 2019-12-12 00:36:35
问题 I've constructed a DataGrid by adding columns programatically using the following snippet: var check = new FrameworkElementFactory(typeof(CheckBox), "chkBxDetail"); dgDetalle.Columns.Add(new DataGridTemplateColumn() { CellTemplate = new DataTemplate() { VisualTree = check } }); for (int i = 0; i < 4; i++) { DataGridTextColumn textColumn = new DataGridTextColumn(); textColumn.Binding = new Binding(string.Format("[{0}]", i)); dgDetalle.Columns.Add(textColumn); } How can I know the checked

Set 2 type controls(TextBox and ComboBox ) in same DataGridTemplateColumn in XAML

你。 提交于 2019-12-11 23:25:51
问题 I have a DataGrid . Inside it contains some columns; 2 are related to this question, one is a DataGridTextColumn ( x:Name="varTypeColumn" ) which show Variable type, another is a DataGridTemplateColumn ( x:Name="varValueColumn" ) which could be a TextBox or ComboBox inside. If varTypeColumn is Bool type, varValueColumn should show a ComboBox which contains 2 items: True , False . If varTypeColumn is Int Type, varValueColumn should show a TextBox which let user input string. So my question is

Hyperlink keeps failing

不羁的心 提交于 2019-12-11 16:08:33
问题 I am trying to create a hypelink which the user can click and navigate to a website. The link is working but I am getting this exception which stops the application: Failed to convert resource into object. The hyperlink will be a part og a datagrid. Here is what I have: XAML: ... <DataTemplate x:Key="hyperlinkTemplate"> <TextBlock> <Hyperlink NavigateUri="{Binding Link}" RequestNavigate="dataLink_RequestNavigate"> <TextBlock Text="{Binding TaskID}"></TextBlock> </Hyperlink> </TextBlock> <

ImageSource from Resources

非 Y 不嫁゛ 提交于 2019-12-11 13:05:13
问题 My Problem: I need a DataGrid with 4 columns. One of them should show an Image. I used DataGridTemplateColumn for this and the others are simple TextColumns. I need different images per row and this is why I need to bind them with the rest of my property's in my Class. I've tried using a property of type Image while setting AutoGenerateColumns="true" and I've tired binding the images path with a string property filled with the path from my project resources but this didn't work either. Does

selection change in wpf template combo box column changes values in other rows

南笙酒味 提交于 2019-12-11 12:51:05
问题 In my project I have a data grid with three combo box template columns and are data bound to three collections and these columns are editable. The collection in the second and third combo box is selected based on the selected index of the combo box in first column when I change selection in first column in any row the change is reflected in all rows. here is my xaml code <DataGrid x:Name="dtg" Grid.Row="2" AutoGenerateColumns="False" CanUserAddRows="True" IsReadOnly="False"

How to modify DatagridTemplateColumn header content runtime in Silverlight?

非 Y 不嫁゛ 提交于 2019-12-11 05:47:59
问题 I defined the DataGridTemplateColumn.HeaderStyle as resource. <UserControl.Resources> <Style x:Key="DataGridHeaderStyleProductName" TargetType="sdk:DataGridColumnHeader"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock x:Name="ProductName" Text="ProductName" /> </StackPanel> </DataTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> I need to modify the Text of TextBlock (ProductName) runtime. How can I modify