Home Forums WPF controls Xceed DataGrid for WPF Problem with ComboBox and Button Column

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • sklabt
    Participant
    Post count: 1
    #43643 |

    Hi,

    we are trying to use the xceed datagrid to replace the Microsoft WPF DataGrid. But we are having some Problems with it.

    the first problem we got is, that we cannot use ComboBoxes like in the DataGrid from Microsoft. In our Example we are binding Data To a ComboBox Column and selecting a Value. For this we are using this XAML:

    <DataGridComboBoxColumn ItemsSource="{Binding Source={StaticResource EnumCollection}}" SelectedValueBinding="{Binding EnumType}" DisplayMemberPath="DisplayName" SelectedValuePath="EnumType" MinWidth="100" Header="Selection"></DataGridComboBoxColumn>

    we created therefore a static source, for selecting the items. this is working properly in the Microsoft DataGrid.

    <CollectionViewSource x:Key="EnumCollection" Source="{Binding EnumMapping}"></CollectionViewSource>

    We are having the following Class besides this:

    internal class EnumMapping
    {
        public MyEnum EnumValue {get;set;}
        public string Caption {get;set;}
    }
    
    public enum MyEnum
    {
      First,
      Secound,
      Third
    }
    

    But we cannot make it work in the Xceed DataGrid. If we are creating a CellContentTemplate, then everytime, when you selecting in a row an item, this is appearing in all rows, but it is only set in the currentrow (we have looked into the collection)

    the result should be, that, if you select a Value in the List, that you are getting the associated enum value via this collection.

    then we are having problems with a button column:

    we are having the following XAML for the ButtonTemplate:

                                <DataGridTemplateColumn Header="Get Value From Selection" MinWidth="200">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="{Binding SelectedValue}" Command="{Binding DataContext.SelectAValue, RelativeSource={RelativeSource AncestorType=local:OurViewModelClass}}" ></Button>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>

    this is working also without problems in the microsoft grid. if you click the button, then a window get’s showed, where you can select something. the selected value is the set by code in the viewmodel, and the data get’s showed in the current row.

    we can show the value in the xceed datagrid, but if we a refreshing the datagridcollectionsource we are always not on the selecteditem. is there a chance to update only the current row? SelectedItem in the datagrid is not working properly.

                                <xcdg:Column FieldName="SelectedValue" Title="Get Value From Selection">
                                    <xcdg:Column.CellContentTemplate>
                                        <DataTemplate>
                                            <Grid>
                                                <TextBlock x:Name="bind_source" Text="{xcdg:CellEditorBinding}" Visibility="Collapsed"/>
                                                <Button Content="{Binding ElementName=bind_source, Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                                        Command="{Binding DataContext.SelectAValue, RelativeSource={RelativeSource AncestorType=local:OurViewModelClass}}" ></Button>
                                            </Grid>
                                        </DataTemplate>
                                    </xcdg:Column.CellContentTemplate>
                                </xcdg:Column>

    it would be very good, if someone can help us.

    thank you for your help in advance!

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    Could you send me a sample project which reproduces the issue so that I could have a closer look. You may send it to: support@xceed.com

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.