wpfdatagrid

Conditional formatting of the font in a WPF Datagrid

此生再无相见时 提交于 2019-12-11 08:28:43
问题 I have a WPF Datagrid populated using a Dataset. I am trying to change the font colour of the data in two columns. I have it working using REMOVED OLD CODE But it isn't holding the colours very well especially when there is scrolling on the grid. It is also slow. Is it possible to do this using an IValueCoverter or is there some other more efficient way to achieve this? EDIT I have tried to take a new approach to this problem. I have created a class to return a bool and then use that bool to

wpf datatable column name can not have slash /

旧城冷巷雨未停 提交于 2019-12-11 07:43:20
问题 I'm very new to WPF. I'm having a very weird issue to just make a table, here is the code I have: DataTable table = new DataTable(); table.Columns.Add("request/sec", typeof(string)); DataRow newRow = dataTable.NewRow(); newRow["request/sec", "na"); but it only shows a column name with "request/sec" and an empty row however, if I do: DataTable table = new DataTable(); table.Columns.Add("test(request/sec)", typeof(string)); DataRow newRow = dataTable.NewRow(); newRow["test(request/sec)", "na");

How to increase the particular row height in the WPF DataGrid when mouse is over that row

丶灬走出姿态 提交于 2019-12-11 07:34:29
问题 I want to increase the particular row height to twice in the WPF DataGrid when mouse is over that row but the remaining rows height should not be changed. When the mmouse moves over on the another row only that row height should be double and the previuos row height should become normal. Please let me know how to do this. Previously i had the following solution. But here when the mouse over a particular row, the row height is doubled but the row is rendered. I don't want this concept, I want

Datagrid (editable issue, access issue) in WPF

我怕爱的太早我们不能终老 提交于 2019-12-11 05:46:23
问题 I created a Datagrid, as shown in this figure --> http://img682.imageshack.us/img682/5109/datagrid.png where user is supposed to enter data. In one of columns, I added Combobox.Now, the Datagrid won't allow me to enter data in the cells. IsReadOnly="False" was also not working, it was giving some "EditMode exception". So, what I did was, I created textblock and within it created combobox and textbox as shown here: <toolKit:DataGrid Width="725" Height="100" HeadersVisibility="Column" Focusable

How to Add dynamic control instead of static control?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 05:36:52
问题 I have a collection with fields cityname, statename and countryname and I bind that collection to my wpf form. I want to display the cityname in a Textbox, the statename in a combobox and the countryname in a combobox. All the textboxes and comboboxes should come dynamically. How can I do this job? Any one suggest me how to design this form dynamically in wpf using MVVM I am trying to do this code but not get result properly. Either I get everything as textbox or combobox, but what i need is

DataGrid Selected Cell Background

谁说我不能喝 提交于 2019-12-11 05:16:44
问题 I'm having trouble with the WPF DataGrid. I have the following code.. <Style TargetType="{x:Type DataGridCell}"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=Content.Text}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridCell}"> <Border Name="DataGridCellBorder"> <ContentControl Content="{TemplateBinding Content}"> <ContentControl.ContentTemplate> <DataTemplate> <TextBlock Width="auto" Height="auto"

WPF datagrid date column with system custom short date format

霸气de小男生 提交于 2019-12-11 04:02:33
问题 This is slightly different wrinkle to the custom date format threads with WPF datagrids. My Win7 box has a custom short date string defined in the Control Panel as dd-MM-yy. I want a date column in a DataGrid to use that setting for display. The view model has a DateTime called 'Date'. I tried this: <DataGrid AutoGenerateColumns="False" Name="dataCondition" ItemsSource="{Binding}"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Name}" ></DataGridTextColumn> <DataGridTextColumn

DataGridTextColumn doesn't allow to enter “double” value

僤鯓⒐⒋嵵緔 提交于 2019-12-11 03:56:54
问题 I have property double? MyDouble { get .. set ... } . I've binded it in DataGridTextColumn: <DataGridTextColumn Binding="{Binding MyDouble}" /> It works fine unless I add UpdateSourceTrigger=PropertyChanged. <DataGridTextColumn Binding="{Binding MyDouble, UpdateSourceTrigger=PropertyChanged}" /> In this case I can't enter "." and add "double" value. How can I avoid this behavior? 回答1: Uninstall .NET 4.5 Beta. I've posted this bug to Microsoft support. 回答2: I think this is related to your

Datagrid (WPF) Column styling programmatically (not xaml)

[亡魂溺海] 提交于 2019-12-11 03:29:17
问题 I have looked on SO but haven't found an exact answer to what I am looking for. I have a DataGrid view bound to a data source. I want to style columns programmatically after the window with the datagrid is visible. I also want to change it from time to time based on some behavior. I tried to use the DataGridTemplateColumn but whenever it runs it deletes the data from those columns. Also I don't get the Cell Style when I try to get it from Resources (i.e. its always null) private void

How to sort data from XML as numeric in a dataGrid

旧时模样 提交于 2019-12-11 02:53:54
问题 I have data in an XML file that I display in a dataGrid. (WPF, C#, VisualStudio 2013) One of the columns is numeric data. When I sort the column, it seems like it is translating it as alpha instead of numeric, though I have tried to specify that column as numeric... XAML for dataGrid: <DataGrid ItemsSource="{Binding Path=Elements[Record]}" AutoGenerateColumns="False" Height="Auto" Name="dataGridRank" VerticalAlignment="Top" HorizontalAlignment="Stretch"> <DataGrid.Columns> <DataGridTextColumn