none
Как сделать фильтрацию элементов второго DataGridComboBox в зависимости от выбранного значения первого DataGridComboBox в DataGrid RRS feed

  • Общие обсуждения

  • <p>Как сделать фильтрацию элементов второго DataGridComboBox в зависимости от выбранного значения первого DataGridComboBox в DataGrid</p>
    <Window x:Class="WpfAppSplit001.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:core ="clr-namespace:WpfAppSplit001.Entities"
            xmlns:core2 ="clr-namespace:WpfAppSplit001.ViewModel"
            xmlns:core3 ="clr-namespace:WpfAppSplit001"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            
            <CollectionViewSource x:Key="filteredCollection"
                              Source="{Binding ddccompanyes}" 
                              Filter="CollectionViewSource_Filter_ddccompanyes"/>
    
        </Window.Resources>
        <Grid>
    
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="18*"/>
                <RowDefinition Height="2*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="9*"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TabControl Grid.Column="1" Margin="0" Grid.Row="2">
                <TabItem Header="TabItem">
                    <Grid Background="#FFE5E5E5" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="7*"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="5*"/>
                        </Grid.ColumnDefinitions>
                        <DataGrid Margin="0" 
                                  Grid.ColumnSpan="3" 
                                  Name="gridpdscompany"
                                  CanUserAddRows="True" 
                                  CanUserDeleteRows="True"
                                  ItemsSource="{Binding}">
                            <DataGrid.Columns>
    
    
                                <DataGridComboBoxColumn x:Name="DGCBC1" Header="Управляющая компания" 
                                                        Width="160"
                                                        DisplayMemberPath="Name_Org_Min"
                                                        SelectedValueBinding="{Binding Path=Manager_id, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                                        SelectedValuePath="idBaseorg" />
                                <DataGridComboBoxColumn x:Name="DGCBC2" Header="Линейный участок" 
                                                        Width="160"
                                                        DisplayMemberPath="Company_name"
                                                        SelectedValueBinding="{Binding Path=Company_id, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                                        SelectedValuePath="Company_id" />
                                <DataGridComboBoxColumn x:Name="DGCBC3" Header="Адрес" 
                                                        Width="40"
                                                        DisplayMemberPath="HomeStreetItems"
                                                        SelectedValueBinding="{Binding Path=IdHome, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                                        SelectedValuePath="IdHome" />
    
                            </DataGrid.Columns>
                        </DataGrid>
    
                    </Grid>
                </TabItem>
                <TabItem Header="TabItem"/>
            </TabControl>
            <Menu Margin="0" Grid.ColumnSpan="3"/>
    
    
        </Grid>
    </Window>

            private void CollectionViewSource_Filter_ddccompanyes(object sender, FilterEventArgs e)
            {
                D_dccompany config = e.Item as D_dccompany;
                if (config != null)
                {
                    if (config.Manager_id == //Как здесь указать ID выбранного значения из первого DataGridComboBox)
                        e.Accepted = true;
                    else
                        e.Accepted = false;
                }
            }

    12 марта 2015 г. 8:35