datagrid

WPF DataGridTemplateColumn Header binding not working

依然范特西╮ 提交于 2020-01-15 03:21:06
问题 I am using the DataGrid with some manually created DataGridTemplateColumns. Here is a code snippet of that in work: <DataGrid ItemsSource="{Binding Projects, Mode=OneWay}" SelectedItem="{Binding SelectedProject}" SelectionMode="Single" CanUserSortColumns="True" RowBackground="Transparent"> <DataGrid.Columns> <DataGridTemplateColumn Header="Art" Width="60" /> <DataGrid.Columns> <DataGrid> Everything works just fine, data is loaded and my column is displayed as expected. However, when i try to

Overriding DataGridTextColumn

℡╲_俬逩灬. 提交于 2020-01-14 12:59:27
问题 I am trying to provide a DataGrid column that behaves like the DataGridTextColumn, but with an additional button in editing mode. I looked at DataGridTemplateColumn, but it appears easier to subclass the DataGridTextColumn as below The problem is the textBox loses its binding when added to the grid. That is, changes to its Text property are not reflected in the non-editing TextBlock or the underlying view-mode Any thoughts on why this might be and how I can work around it? public class

How to show a message (ex: No records found!) in the table when no records is returned?

人盡茶涼 提交于 2020-01-14 06:35:29
问题 I am using easyui datagrid in my application.How to show a message (ex: No records found!) in the table when no records is returned? $('#test').datagrid({ onLoadSuccess:function(data){ if(data.total == 0){ alert("No Records founds"); } } }); 来源: https://stackoverflow.com/questions/16399567/how-to-show-a-message-ex-no-records-found-in-the-table-when-no-records-is-re

WPF Datagrid-Change background color of the row for which the button is clicked

此生再无相见时 提交于 2020-01-14 05:37:48
问题 I have a data grid in my wpf application. I wants that when user clicks on any button in the datagrid the corresponding row should be red. I think we can do it by using event trigger but i really don't know how to use it. <DataGrid x:Name="dgEmp" Grid.Row="1" AutoGenerateColumns="False" CanUserAddRows="False" > <DataGrid.Columns> <DataGridTextColumn Header="Name" Width="*" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="Age" Width="*" Binding="{Binding Path=Age

WPF 数据绑定TreeView+DataGrid+XML

≯℡__Kan透↙ 提交于 2020-01-14 04:53:51
学习WPF做的一个数据绑定例子,可供学习参考。 实现功能:WPF通过读取XML数据绑定到TreeView, 在通过TreeView选择项(Node)获取的对应的数据绑定到DataGrid控件上,再通过DataGrid选中行的详细信息数据绑定到DataGrid。 首先创建XML数据 <?xml version="1.0" encoding="utf-8" ?> <root> <category name="Computer"> <product name="联想笔记本"> <order orderId="1" orderName="cizon的订单" orderDate="2012-11-10"> <orderInfo productName="联想笔记本" unitPrice="3000" count="2"> </orderInfo> </order> <order orderId="2" orderName="steven的订单" orderDate="2012-11-10"> <orderInfo productName="联想笔记本" unitPrice="3000" count="2"> </orderInfo> </order> </product> <product name="宏基笔记本"> <order orderId="1" orderName="Luly的订单

Binding WPF DataGrid to List<Interface>

吃可爱长大的小学妹 提交于 2020-01-14 03:39:13
问题 Hello I have a DataGrid and I have different reports that I want to show. I'm going to change the classes so they are shorter in here but Idea is the same. Lets say that I Have an Interface called IReports public interface IReports { } and three classes called Students, Classes, Cars public class Students:IReports { public string Name { get; set; } } public class Classes : IReports { public string ClassName { get; set; } public string StudentName { get; set; } } public class Cars : IReports {

DataGrid button - Invalid Postback or Callback

孤街醉人 提交于 2020-01-13 20:40:11
问题 I have setup a DataGrid with a number of columns and a checkbox and column at the end of the row. I am also changing the layout of the datagrid on the OnItemCreated event which changes the layout of the datagrid by expanding the rows with the "Rowspan" attribute and remove the extra columns and controls where they are no longer required. The original datagrid layout was setup like this: ___________________________________________ | 1 | Employee Name | 01/08/10 |[] |[SAVE]| | 1 | Employee Name

WPF MVVM: Display View for DataGrid's SelectedItem

[亡魂溺海] 提交于 2020-01-13 20:30:08
问题 I'm new to MVVM and WPF and have been completely hung up on this issue for some time now. I'm trying to display a View (UserControl) based on the SelectedItem in a DataGrid. The UserControl renders with the data set in the constructor, but never updates. I would really appreciate some insight from someone with experience in this. I tried adding a Mediator via setUpdateCallback and now the first row in the datagrid updates with the values of the other rows I click on, but this obviously isn't

WPF MultiDataTrigger AND condition

房东的猫 提交于 2020-01-13 10:22:08
问题 I would like to enable a button only when both of my two datagrids have selected items. Right now it is enabled when either of the datagrids have selections. Any ideas? <Button x:Name="button" Content="Z" Grid.Column="1" Margin="0,240,0,0" VerticalAlignment="Top" FontFamily="Wingdings 3" FontSize="21.333" ToolTip="Set the selected alarm for the selected alarm time"> <Button.Style> <Style TargetType="Button"> <Setter Property="IsEnabled" Value="True" /> <Setter Property="Opacity" Value="1" />

Conditionally making readonly to WPF DataGridCell

独自空忆成欢 提交于 2020-01-13 08:01:28
问题 I have a situation that needs to conditionally make readonly to wpf datagrid cell. There is IsReadOnly property in DataGridCell. But unfortunately, that property is readonly! Is there any way to do it? ant. 回答1: You should be able to use the DataGrid.BeginningEdit event to conditionally check if the cell is editable and then set the Cancel property on the event args if not. 回答2: The similar solution as Goblin above, but with a little code samples: The idea is to dynamically switch the