wpfdatagrid

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

Conditionally making readonly to WPF DataGridCell

非 Y 不嫁゛ 提交于 2020-01-13 08:01:09
问题 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

WPF Datagrid “Select All” button - “Unselect All” too?

旧时模样 提交于 2020-01-11 04:45:09
问题 I would like to know if it would be possible to add functionality to the 'Select All' button in the top left of a datagrid so that it also unselects all rows? I have a method attached to a button which does this, but it would be great if I could fire this method from the Select All button, to keep functionality in the same part of the view. Can this 'Select All' button have code added to it, and if so, how would one get to the button? I haven't been able to find any examples or suggestions.

How to stop DataGrid row color from changing?

放肆的年华 提交于 2020-01-07 06:43:31
问题 I've implemented code to get around the double click issue when selecting a row in a WPF DataGrid. I'm using the following code from here: https://stackoverflow.com/a/5857908/40106. <Style TargetType="DataGridCell"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="IsEditing" Value="True" /> </Trigger> </Style.Triggers> </Style> Rows have alternating colors. The problem is when I mouse over a row, in one column, the light blue color is replaced by white. The

Connection to Read-only embedded SQL Server compact edition (.sdf file) in WPF application

天涯浪子 提交于 2020-01-06 20:24:15
问题 I am looking for a solution to the following: Find a properly formatted connection string to SQL server compact edition file (.sdf) used as embedded resource, containing reference (i.e. read-only) data in WPF application. Note: please pay attention to the operative words [ Build Action ] set to " Embedded Resource " and " Do Not Copy " to the output directory settings. It means that the file will not be physically copied to the target computer as a stand-alone entity, but instead is embedded

IValueConverter executes more times than expected

安稳与你 提交于 2020-01-06 20:05:47
问题 I have a converter that takes the text from a TextBlock that makes up a DataGridCell and converts it to a red or black brush depending if the value is negative or positive. However the converter executes more times than there are items in the datasource of the grid. For example if I simply bind a collection that contains 1 object, the converter executes 2 times. The first time the value parameter is an empty string, the second time it actually contains the value that I would expect. If I add

IValueConverter executes more times than expected

让人想犯罪 __ 提交于 2020-01-06 20:03:40
问题 I have a converter that takes the text from a TextBlock that makes up a DataGridCell and converts it to a red or black brush depending if the value is negative or positive. However the converter executes more times than there are items in the datasource of the grid. For example if I simply bind a collection that contains 1 object, the converter executes 2 times. The first time the value parameter is an empty string, the second time it actually contains the value that I would expect. If I add

How to show a grand Total by adding all the prices in the dataGrid column (wpf)

寵の児 提交于 2020-01-06 08:28:10
问题 I have this datagrid which shows the following data when i click on add button. what i want is to show the grand_total at the bottom of the grid Dynamically(the area is highlighted in in yellow color) i have search alot but i am unable to access any datagrid footer or things like that, also i am very new in WPF My Xaml CODE: <DataGrid x:Name="dataGrid" CanUserAddRows="True" ItemsSource="{Binding ''}" AutoGenerateColumns="False" HorizontalAlignment="Left" VerticalAlignment="Top" Height="207"

Persist sorting from DataGrid to ItemsSource collection

隐身守侯 提交于 2020-01-06 03:25:26
问题 I have a DataGrid and I'm trying to do the Sort thing the most straightforward way: by clicking on the header of each column. This is working great on the View ( in the MVVM context ), but I want to sort the underlying ViewModel collection ( ObservableCollection ) too. Any suggestions on how to implement the source collection? 回答1: Bind the grid to a ListCollectionView , initialised with the ObservableCollection . The grid will use your pre-created ICollectionView instead of creating it's own

conditional formatting in wpf toolkit datagrid

左心房为你撑大大i 提交于 2020-01-06 03:18:09
问题 hey i wanna change row foreground color according to a boolean in the model, whats the best way of doing it? 回答1: Define the style as following (IsBlah is a boolian property): <Style x:Key="MyRowStyle" TargetType="{x:Type dg:DataGridRow}"> <Setter Property="Background" Value="White"/> <Setter Property="Foreground" Value="DarkBlue"/> <Style.Triggers> <DataTrigger Binding="{Binding IsBlah}" Value="False" > <Setter Property="Background" Value="DarkGray" /> <Setter Property="Foreground" Value=