datagridcomboboxcolumn

Binding SelectedItem of ComboBox in DataGrid with different type

我的未来我决定 提交于 2019-12-12 09:01:39
问题 I have a DataGrid which contains ComboBox as column. Let consider DataGrid having ItemsSource as ObservableCollection and ComboBox ItemsSource is List . I want to set the ComboBox SelectedItem property based on property in DataGrid ItemsSource. However Product class has property ProductTypeId of type int and not ProductType. So how can I set ComboBox SelectedItem so that it display value of Product.ProductTypeId as selected. And also I want to bind SeletedItems with Mode = TwoWay so that

WPF DataGridComboBoxColumn different ItemsSource for a specific row

帅比萌擦擦* 提交于 2019-12-12 03:53:09
问题 I am trying to give a new ItemsSource to a DataGridComboBoxColumn in a specific row in my program when the selection of an other DataGridComboBoxColumn in the same row is changed. The problem is that I am only able to change the ItemsSource of all rows at the same time. Is it possible to give a specific ItemsSource for a DataGridComboBoxColumn to only one row in a Datagrid ? This is the declaration of my DataGrid and my DataGridComboBoxColumn <DataGrid Name="DATAGRIDSEARCH"

Bind ViewModel property to DataGridComboBoxColum

烂漫一生 提交于 2019-12-12 02:44:28
问题 I am trying to use an enum in a Datagrid. Let me show you two ways that it can work. First, I create a ComboBox inside the DataGrid, the DataContext.MyOptions returns a list of Strings for all values of enum. <DataGridTemplateColumn Header="Enum1"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding DataContext.MyOptions, RelativeSource={RelativeSource AncestorType=Window}}" SelectedItem="{Binding Enum1, UpdateSourceTrigger=PropertyChanged, Converter=

Center content in combobox within datagridcomboboxcolumn through xaml within style

天大地大妈咪最大 提交于 2019-12-11 20:48:51
问题 my first question, so please be gentle. I have tried for several days to figure it out. The closest I got was to programmatically access the content of the cell in the code behind. Is there a way to do it in the xaml? For instance, this doesn't work <Style x:Key="ComboBox" TargetType="DataGridCell"> <Setter Property="FontSize" Value="14"/> <Setter Property="FontWeight" Value="SemiBold"/> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment"

WPF DataGrid - Dynamically Bind DataGridComboBoxColumn based on row

守給你的承諾、 提交于 2019-12-11 11:08:51
问题 I have an ObservableCollection of objects. These object are displayed in a DataGrid & a `SelectedObject I have a property PossibleParentObjects that returns a List of Objects based on the SelectedObject. I would like to have this property populate a ComboBox residing in a column of the DataGrid How can I do this? Here is what I have so far... Obviously not working: <DataGrid Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AlternatingRowBackground="AntiqueWhite"

WPF DataGridComboBoxColumn style

好久不见. 提交于 2019-12-11 07:57:56
问题 I use ComboboxColumn in DataGrid which works fine. However there is a style issue: When cursor is not on the column, the ComboboxColumn looks like a textboxColumn . Once I click it, a tiny arrow on the right corner displays so it looks like a combobox. I want it to display like a combobox even when it is not clicked or focused. I feel it is ElementStyle , but not sure what to change to exactly. Does someone know how to do this? xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit" <dg

DataGridComboBoxColumn is empty

别来无恙 提交于 2019-12-11 06:28:14
问题 My DataGridComboBoxColumn does not show any data. It's empty. I have no problem to fill a ComboBox, but DataGridComboBoxColumn doesn't work. .NetFramework 4.6.1 Model: public class Address { public string Firstname { get; set; } public string Lastname { get; set; } public string Country { get; set; } } ViewModel: public class AddressViewModel { public AddressViewModel() { LoadAdresses(); LoadCountries(); } public List<Address> AddressList { get; set; } public List<string> CountryList { get;

WPF Datagrid DataGridComboBoxColumn cells displayed value set during the AutoGeneratingColumn event

梦想与她 提交于 2019-12-11 00:15:59
问题 I have a DataGrid ComboBox Column that is bound to an Observable Collection of ComboBoxOption objects, these objects just contain 2 values, one that is the value displayed to the user and the other the required value. I am setting the bindings etc. during the AutoGenerating Columns event and this is all working fine. The problem I am having is trying to make the combo box display the required value only. This cannot be done in the XAML (Unless I can set up a column template in the XAML and

Dynamic ComboBox in a DataGridView

白昼怎懂夜的黑 提交于 2019-12-08 03:18:31
问题 I have a DataGridView with 4 columns, one of them being a drop-down (ComboBox) column. The values in this column must be distinct so once a given drop-down values is selected in a row, I'd like it to not be available in any of the drop-downs in other rows. If a given value is unselected it should show up in the drop-downs again. I found a few articles with similar examples (1,2,3); however, all of them seem to involve subscribing to an event and manually populating the ComboBox. Is there a

WPF DataGridComboBoxColumn`s ComboBox is only visible when DataGrid has IsReadOnly=FALSE

最后都变了- 提交于 2019-12-06 04:45:57
问题 Why is the ComboBox in that column only visible via double-click in the empty cell when the DataGrid is set to IsReadOnly = FALSE ??? <DataGridComboBoxColumn Width="*" IsReadOnly="False" Header="test" /> using a DataTemplateColumn works as always... whats wrong with that DataGridComboBoxColumn? works: <DataGridTemplateColumn Header="Schoolclass"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox Background="Blue" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <