15
Multi-Selection XamComboEditor in XamDataGrid SelectedItems Binding Issue
posted

Hello, 

We have a Multi-Selection XamComboEditor in XamDataGrid. The Multi-Selection XamComboEditor ItemSource is binded to an ObservableCollection, which belongs to our UserViewerViewModel. However, rows from the the XamDataGrid are binded to UserViewerModel. And each row is a UserViewerModel. The Multi-Selection column is called "Application Roles", which corresponds to ObservableCollection<Role> inside UserViewerModel. We have a list of UserVIewerModel in UserViewerViewModel, 

My Question is: How do we bind the SelectedItems of the Multi-Selection XamComboEditor to the ObservableCollection<Role> inside UserViewerModel. I have spent 2 days on this issue and cannot resolve it. Attached is our code: 

<UserControl x:Class="NorthPoint.Rir.Common.UI.Authorizations.Views.UserViewerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"             
             xmlns:igDP="http://infragistics.com/DataPresenter"
             xmlns:ig="http://schemas.infragistics.com/xaml"
             xmlns:igEditors="http://infragistics.com/Editors"
             xmlns:grids="clr-namespace:NorthPoint.Rir.Common.UI.Extensions.Grids"
             xmlns:views="clr-namespace:NorthPoint.Rir.Common.UI.Viewer.Views"
             xmlns:converters="clr-namespace:NorthPoint.Rir.Common.UI.ValueConverters"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:behavior="clr-namespace:NorthPoint.Rir.Common.UI.Behavior"
             xmlns:models="clr-namespace:NorthPoint.Rir.Common.Biz.Loaders.Models;assembly=NorthPoint.Rir.Common.Biz"
             DataContext="{Binding UserViewerViewModel, Source={StaticResource ViewModelLocator}}" Background="{StaticResource SolidDialogBgBrush}">
    <UserControl.Resources>
        
        <Style x:Key="MultiRoles" TargetType="{x:Type igDP:CellValuePresenter}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <ig:XamComboEditor  ItemsSource="{Binding DataContext.Roles, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}"
                                            DisplayMemberPath="Name"
                                            AllowMultipleSelection="True" 
                                            CheckBoxVisibility="Visible"
                                            Loaded="ComboBox_Loaded"
                                            SelectionChanged="ComboBox_SelectionChanged">
                        </ig:XamComboEditor>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
         <grids:RirXamDataGrid Grid.Column="0" Grid.Row="1" IsSynchronizedWithCurrentItem="True" 
                                  x:Name="RefDataGrid"
                                  ActiveDataItem="{Binding SelectedUser, Mode=TwoWay}"
                                  SelectedEntities="{Binding SelectedItems}"
                                  Style="{StaticResource XamDataGridStyle}"
                                  DataSource="{Binding ReferenceDataItems, Mode=TwoWay}" ScrollingMode="Immediate"
                                  GroupByAreaLocation="None">
                <i:Interaction.Behaviors>
                    <behavior:RowNumberBehavior />
                </i:Interaction.Behaviors>
                <grids:RirXamDataGrid.InputBindings>
                    <KeyBinding Key="Delete" Command="{Binding DeleteCommand}" />
                </grids:RirXamDataGrid.InputBindings>
                <igDP:XamDataGrid.FieldLayoutSettings>
                    <igDP:FieldLayoutSettings AllowClipboardOperations="Copy" AllowAddNew="True"
                                              AutoGenerateFields="False"
                                              AddNewRecordLocation="OnBottomFixed"
                                              DataRecordSizingMode="SizedToContentAndIndividuallySizable"
                                              DataErrorDisplayMode="ErrorIconAndHighlight"
                                              SupportDataErrorInfo="RecordsAndCells" />
                </igDP:XamDataGrid.FieldLayoutSettings>
                <igDP:XamDataGrid.FieldSettings>
                    <igDP:FieldSettings AllowEdit="True" CellClickAction="EnterEditModeIfAllowed" AutoSizeOptions="All"
                                        Width="Auto"
                                        AllowRecordFiltering="True" FilterLabelIconDropDownType="MultiSelectExcelStyle"
                                        AllowHiding="Always" />
                </igDP:XamDataGrid.FieldSettings>
                <igDP:XamDataGrid.FieldLayouts>
                    <igDP:FieldLayout>
                        <igDP:FieldLayout.Fields>
                            <igDP:Field Name="UserId">
                                <igDP:Field.Settings>
                                    <igDP:FieldSettings AllowEdit="False" />
                                </igDP:Field.Settings>
                            </igDP:Field>
     
                            <igDP:Field Name="Roles" Width="200">
                                <igDP:Field.Settings>
                                    <igDP:FieldSettings CellValuePresenterStyle="{StaticResource MultiRoles}"/>
                                </igDP:Field.Settings>
                            </igDP:Field>
                        </igDP:FieldLayout.Fields>
                    </igDP:FieldLayout>
                </igDP:XamDataGrid.FieldLayouts>
                <igDP:XamDataGrid.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="View Authorized Tasks" Command="{Binding ViewAuthorizedTasksCommand}"/>
                        <MenuItem Header="View Audit History" Command="{Binding ViewAuditHistoryCommand}">
                            <MenuItem.Icon>
                                <Image Width="16px"
                                       Source="/NorthPoint.FormPf.Common.UI.Wpf;component/Images/clock.png" />
                            </MenuItem.Icon>
                        </MenuItem>
                    </ContextMenu>
                </igDP:XamDataGrid.ContextMenu>
            </grids:RirXamDataGrid>

Parents Reply Children
No Data