wpfdatagrid

How to bind property name to which column is binded to pass as command parameter

試著忘記壹切 提交于 2019-12-04 21:03:09
On each DataGridColumnHeader I have a button that I use to open a popup. As a parameter it sends the column's bound Property name to the ICommand in my ViewModel. This works well for any DataGridTextColumn however when it comes to a DataGridComboBoxColumn the structure is different. How would I solve this? <Button Command="{Binding DataContext.OpenFilterCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding Column.Binding.Path.Path, RelativeSource={RelativeSource Mode=TemplatedParent}}"/> Problem Column Definition <DataGridComboBoxColumn Header="Company"

Showing a new Window right next to a DataCell in DataGrid (WPF)

落爺英雄遲暮 提交于 2019-12-04 19:19:41
I want a scenario when a user clicks on a cell in DataGrid in WPF, I want to open NumPad next to it (This is basically for touch based input). The NumPad, I understand is a separate window. 1) How can I know which Cell is selected 2) how can I show the NumPad next to the cell? 3) How can I find the coordinates of cell to position my NumPad? 4) How can I set the value of cell based on NumPad entry? NumPad is a WPF User Control in the same application. DataGrid is a .NET 4 Control. It's a normal Windows Desktop application This is not a trivial task and you should have some knowledge of WPF to

How to bind the same collection of values into all ComboBoxes in a DataGridComboBox?

喜你入骨 提交于 2019-12-04 18:17:54
I have a Collection of Values in an Array of Strings, or in a List or whatever, and what i want is to set this Collection of values as the Collection of items into all the ComboBoxes in a column as DataGridComboBoxColumn in WPF. I think i don't have other way to access this Collection of Values and bind it equally to all the ComboBoxes (in XAML) beside the DataContext. But can i access the DataContext of a DataGrid from a DatGridComboBoxColumn (in XAML)? Can i do it? How? How i specify (in XAML) in DatagridComboBoxColumn to put this Collection of Items equally in all ComboBoxes? How i can

How to change Text of TextBlock which is in DataTemplate of Row Details for each DataGrid Row Details?

回眸只為那壹抹淺笑 提交于 2019-12-04 15:21:43
I have Datagrid which is clicking by mouse in each row is showing data grid row details. here is code, Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(DataGrid1.ItemContainerGenerator.ContainerFromItem(DataGrid1.SelectedItem)); DataGridDetailsPresenter presenter = FindVisualChild<DataGridDetailsPresenter>(row); DataTemplate template = presenter.ContentTemplate; TextBlock txt = (TextBlock)template.FindName("rowdetails", presenter); txt.Text = retString; And also I have Checkbox, when you check it, it should show all row details. I am trying this code for

WPF DataGrid: resizing columns

邮差的信 提交于 2019-12-04 14:03:28
I have a System.Windows.Controls.DataGrid with property CanUserResizeColumns assigned to True. Now I can adjust the width of the columns by using the mouse left button click between 2 column headers. But I also want to be able to change the width of the columns in any row of the dataGrid, not only in the column headers. Is it possible? In your dataGrid you can use a DataGridTemplate column alogn with a GridSplitter to achieve this.. <toolkit:DataGridTemplateColumn Header="Text" > <toolkit:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition

two way wpf datagrid binding to database

亡梦爱人 提交于 2019-12-04 12:22:39
HI all, I want to bind WPF datagrid in two way. I had tried following XAML: <Grid> <my:DataGrid x:Name="dataGrid" AutoGenerateColumns="False" Margin="8"> <my:DataGrid.Columns> <my:DataGridTextColumn Header="Header" Binding="{Binding pCode}" IsReadOnly="True" /> <my:DataGridTextColumn Header="Header" Binding="{Binding pName}" IsReadOnly="True" /> <my:DataGridTextColumn Header="Header" Binding="{Binding pStock}" IsReadOnly="True" /> <my:DataGridTextColumn Header="Header" Binding="{Binding pGroup}" IsReadOnly="True" /> <my:DataGridTextColumn Header="Header" Binding="{Binding pPrice, Mode=TwoWay,

Button inside a WPF List view/data grid

こ雲淡風輕ζ 提交于 2019-12-04 12:18:31
I am trying to get the value/ID of the clicked row. If the row is selected, this works fine. But if I just try to click the button inside, the selected customer is null. How do I do Command Parameters here. I tried this see the answers to the following questions: ListView and Buttons inside ListView WPF - Listview with button Here is the code: <Grid> <ListView ItemsSource="{Binding Path=Customers}" SelectedItem="{Binding Path=SelectedCustomer}" Width="Auto"> <ListView.View> <GridView> <GridViewColumn Header="First Name"> <GridViewColumn.CellTemplate> <DataTemplate> <StackPanel Margin="6,2,6,2"

How to Select All check box together in WPF datagrid

妖精的绣舞 提交于 2019-12-04 11:36:29
my wpf data grid is, <dg:DataGrid.Columns > <dg:DataGridTemplateColumn> <dg:DataGridTemplateColumn.Header> <CheckBox Content=" Slect All" Click="CheckBox_Click" /> </dg:DataGridTemplateColumn.Header> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox Name="chkSelectAll" Margin="45 2 0 0" Click="chkSelectAll_Click" /> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> </dg:DataGridTemplateColumn> <dg:DataGridTemplateColumn Header="Edit Row" > <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Content="Edit" Click="Button_Click" /> </DataTemplate> </dg

WPF Datagrid RowDetailsTemplate visibility bound to a property

我是研究僧i 提交于 2019-12-04 10:31:19
问题 I am using a WPF Datagrid with a RowDetails panel where the RowDetailsVisibilityMode is set to "VisibleWhenSelected" and the SelectionMode="Extended" so that multiple rows can be selected and hence display RowDetails, as below: <dg:DataGrid x:Name="MyGrid" ItemsSource="{Binding Path=MyItems}" AutoGenerateColumns="True" SelectionMode="Extended" RowDetailsVisibilityMode="VisibleWhenSelected"> <dg:DataGrid.RowDetailsTemplate> <DataTemplate> <TextBlock Text="Further Details..."/> </DataTemplate>

How do you rename DataGrid columns when AutoGenerateColumns = True?

与世无争的帅哥 提交于 2019-12-04 09:13:42
问题 I have a simple data structure class: public class Client { public String name {set; get;} public String claim_number {set; get;} } Which I am feeding into a DataGrid : this.data_grid_clients.ItemSource = this.clients; I would like to change the column headings. Ie: claim_number to "Claim Number". I know this can be done when you manually create the columns by doing something like: this.data_grid_clients.Columns[0].Header = "Claim Number" However, the Columns property is empty when auto