datagrid

Relative Column Widths Not Working When DataGrid is Nested Inside A Grouped DataGrid

时光毁灭记忆、已成空白 提交于 2020-01-21 12:20:47
问题 Suppose I have an object with 6 attributes: public class MyClass { public string Attribute1 { get; set; } public string Attribute2 { get; set; } public string Attribute3 { get; set; } public string Attribute4 { get; set; } public string Attribute5 { get; set; } public string Attribute6 { get; set; } } I display a collection of these objects in a DataGrid: <Grid> <DataGrid x:Name="myGrid" Margin="5, 5, 5, 5" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="True"> <DataGrid

WPF DataGridTemplateColumn Visibility Binding under MVVM

别来无恙 提交于 2020-01-21 09:03:46
问题 I have a DataGrid bound to an ICollectionView in my ViewModel. The DataGrid is inside a UserControl which is used in a few different data scenarios, some of which require certain DataGrid columns while others don't. I just want to bind the DataGridTemplateColumn's Visibility property to the inner label's Content property so if none of the rows contain a value, it will be hidden. I have a String to Visibility converter set, but can't figure out how to find the inner lable's Content property.

WPF DataGridTemplateColumn Visibility Binding under MVVM

百般思念 提交于 2020-01-21 09:03:25
问题 I have a DataGrid bound to an ICollectionView in my ViewModel. The DataGrid is inside a UserControl which is used in a few different data scenarios, some of which require certain DataGrid columns while others don't. I just want to bind the DataGridTemplateColumn's Visibility property to the inner label's Content property so if none of the rows contain a value, it will be hidden. I have a String to Visibility converter set, but can't figure out how to find the inner lable's Content property.

Programatically bringing a Datagrid column into view (horizontal scroll)

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-21 07:36:14
问题 I would like to bring a column into view programatically. I have a lot of columns and when they are off screen i would like to select a cell and bring that cell into view, i can select a cell that is off screen and when i horizontal scroll to bring the cell visible the cell is selected. i know you can do this with the rows, i.e ScrollIntoView but how about columns? anyone had any luck doing this? and if so how :) (of course) 回答1: Answer : use the datagrid method. public void ScrollIntoView

WPF 修改DataGrid选中行时的颜色

走远了吗. 提交于 2020-01-17 18:27:26
只要修改DataGridCell的Style就可以了。 包括具体子项被选中时 <Style TargetType="{x:Type DataGridCell}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="Black" /> </Trigger> <Trigger Property="IsFocused" Value="true"> <Setter Property="Background" Value="Red" /> </Trigger> </Style.Triggers> </Style> 来源: https://www.cnblogs.com/T-ARF/p/12206869.html

different kinds of cells in the same column

*爱你&永不变心* 提交于 2020-01-17 11:15:17
问题 I need to render a datagrid with different kinds of cells in the same column. For example, I have a datagrid with a column "name" and a column "value". Depending on the "type" of my record, I would have different cells in the column "value" like a combobox or a simple textfield. and I don't really see how to do that programmatically... I don't know if the datagrid is the best choice. Any hint? I'm using asp.net/vb.net with framework 3.5 回答1: You can do that using the user control, where you

different kinds of cells in the same column

…衆ロ難τιáo~ 提交于 2020-01-17 11:12:06
问题 I need to render a datagrid with different kinds of cells in the same column. For example, I have a datagrid with a column "name" and a column "value". Depending on the "type" of my record, I would have different cells in the column "value" like a combobox or a simple textfield. and I don't really see how to do that programmatically... I don't know if the datagrid is the best choice. Any hint? I'm using asp.net/vb.net with framework 3.5 回答1: You can do that using the user control, where you

DataGrid导出Excel

假如想象 提交于 2020-01-17 06:24:28
DataGrid导出Excel Table title; Response.Clear(); Response.Buffer= true; Response.Charset="utf-8"; Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls"); Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");//设置输出流为简体中文 Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 this.EnableViewState = false; System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo( "ZH-CN",true); System.IO.StringWriter oStringWriter = new System.IO.StringWriter( myCItrad); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI

Update WPF DataGrid ItemSource from Another Thread in PowerShell

孤人 提交于 2020-01-17 05:08:11
问题 I have datagrid that gets updated when a button is clicked. However in some cases the data is taking 30 seconds+ to return and the Window freezes. I want to be able to get the data and populate the datagrid from another thread so as not to hang the main window. The DataGrid is read only. Eventually want to have a "cancel" button and animation to indicate progress, but for now just want to get this working. I made a sample program that can demonstrate the issue, which was based on http://learn

Update WPF DataGrid ItemSource from Another Thread in PowerShell

℡╲_俬逩灬. 提交于 2020-01-17 05:08:03
问题 I have datagrid that gets updated when a button is clicked. However in some cases the data is taking 30 seconds+ to return and the Window freezes. I want to be able to get the data and populate the datagrid from another thread so as not to hang the main window. The DataGrid is read only. Eventually want to have a "cancel" button and animation to indicate progress, but for now just want to get this working. I made a sample program that can demonstrate the issue, which was based on http://learn