I am developing a WPF 4.0 application where I need to create a grid on the text column box or dropdown There is a column with a quarrel. Example:
| Name | Price | Help | | PROP1A | [Text box] | Details of Prop1a | | Prop 2a | [Dropdown V] | Details of Prop2a | | Prop3A | [Text box] [x checkbox] | Details of Prop2a | | Contact 4A | [Dropdown V] | Details of Prop2a | | Etc .. This is the idea that there is a table of values of the user that they require input, and we display names and details for each value together. There are some standard numbers that require input with textbox, while others have one textbox and one checkbox, and yet there are other dropdowns. My initial thought was to originally store what I would call the Rodiscriptor s, which will specify the name, input type and support information (which is just text) And then on the datagrid to use binding to the collection. As a matter of fact, these views act as modals, and setting values in the datagrid will flow through real-time models (such as in a specific case for an MVVM app) through the View Modal.
As I have seen documentation available to me, however, I could not find anywhere, in this way a way to dynamically change the type of column was discussed. I am now leaning towards using a grid instead, and manually laying input (still using binding, but each element is separate binding). Although this will have a lot of manual effort on my part, I had to find out if my first thought was a relatively simple way of implementing. It seems that I should be able to do something with DataGridTemplateColumn, but I'm relatively new to WPF and I'm not sure how I would like to go about doing this.
You can use a template column.
This will show one or two text boxes based on the data in one line.
A cell template is shown normally, but when the cell is edited it is replaced by the cell editing template.
& lt; DataGridTemplateColumn header = "value" width = "350" & gt; & Lt; DataGridTemplateColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; TextBlock Text = ToolTip = "{Binding EffectiveValue, mode = Oneway}" TextWrapping = "Wrap" / & gt "{EffectiveValue, mode = Oneway, ValidatesOnDataErrors = true binding}"; & Lt; / DataTemplate & gt; & Lt; /DataGridTemplateColumn.CellTemplate> & Lt; DataGridTemplateColumn.CellEditingTemplate & gt; & Lt; DataTemplate & gt; & Lt; Grid & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "Auto" /> & Lt; Column width = "*" /> & Lt; /Grid.ColumnDefinitions> & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition Height = "Auto" /> & Lt; RowDefinition Height = "Auto" /> & Lt; /Grid.RowDefinitions> & Lt; TextBlock Text = "Value" margin = "4" /> & lt; Textbox Grid.Column = "1" Text = "{ConfigurationValue binding, ValidatesOnDataErrors = true}" ToolTip = "{Binding ConfigurationValue}" TextWrapping = "Wrap" AcceptsReturn = "{Binding data type, mode = Oneway, Converter = {StaticResource ResourceKey = StringMatchBooleanConverter}, converter Parameter = String} "GUI: FocusAttacher.Focus =" True "/> & Lt; TextBlock Text = "default values" Grid.Row = "1" Margin = "4" visibility = "{DefaultConfigurationValue binding, Converter = {StaticResource ResourceKey = NullVisibilityConverter}}" / & gt; & Lt; True text box Grid.Column = "1" Grid.Row = "1" Text = "{Binding DefaultConfigurationValue, mode = Oneway}" ToolTip = "{Binding DefaultConfigurationValue, mode = Oneway}" TextWrapping = "Wrap" IsReadOnly = " "Visibility =" {Binding DefaultConfigurationValue, Converter = {StaticResource ResourceKey = NullVisibilityConverter}} "/> & Lt; / Grid & gt; & Lt; / DataTemplate & gt; & Lt; /DataGridTemplateColumn.CellEditingTemplate> & Lt; / DataGridTemplateColumn & gt;
Comments
Post a Comment