0

是否可以将筛选行从XCeed DataGrid 控件拉出到其他地方,如组框?如果可能,怎么做?任何指针将不胜感激。

请考虑下面给出的场景,当我单击过滤器按钮时,产品名称列将根据过滤器查询进行过滤。为了做到这一点,我需要为Product Name取出 FilterRow Cell 。

替代文字

4

3 回答 3

3

您可以在 Xceed DataGrid 附带的演示文件中获得一个完整的示例,该示例准确地显示了您需要的内容。

它在您的硬盘驱动器上的默认位置是:

外部自动滤波器控制C:\Xceed Samples\Xceed DataGrid for WPF Professional Edition v4.2\CSharp\CustomFiltering

这是一个代码片段,它显示了如何使用绑定到您需要的相应 DataGrid 列的 AutoFilterControl 来执行此操作。

<GroupBox x:Name="groupBox" Header="Auto-filter Actions"
                  Margin="{StaticResource groupBoxMargin}"
                  Padding="{StaticResource groupBoxPadding}"
                  Grid.Column="0">
           <StackPanel x:Name="stackPanel">
              <!-- ComboBoxes for automatic filtering -->
              <Grid Grid.Column="2"
                    HorizontalAlignment="Right">
                 <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="135" />
                    <ColumnDefinition />
                 </Grid.ColumnDefinitions>

                 <Grid.RowDefinitions>
                    <RowDefinition MinHeight="30" />
                    <RowDefinition MinHeight="30" />
                    <RowDefinition MinHeight="30" />
                 </Grid.RowDefinitions>

                 <!--ShipCountry combo box-->
                 <TextBlock Text="Country"
                            Grid.Column="0"
                            Grid.Row="0"
                            Margin="5,2,5,2"
                            VerticalAlignment="Center" />

                 <xcdg:AutoFilterControl x:Name="shipCountryAutoFilterControl"
                                         Grid.Column="1"
                                         Grid.Row="0"
                                         AutoFilterColumn="{Binding ElementName=grid, Path=Columns[ShipCountry]}"
                                         AutoFilterContext="{Binding ElementName=grid, Path=(xcdg:DataGridControl.DataGridContext)}"
                                         Focusable="False"
                                         Width="Auto">
                    <xcdg:AutoFilterControl.Template>
                       <ControlTemplate TargetType="{x:Type xcdg:AutoFilterControl}">

                          <ComboBox x:Name="PART_DistinctValuesHost"
                                    Grid.Column="1"
                                    ItemTemplate="{Binding Source={StaticResource countryComboBoxDataTemplate}}"
                                    Initialized="OnShipCountryComboBoxInitialized"
                                    Margin="5,2,5,2" />

                       </ControlTemplate>
                    </xcdg:AutoFilterControl.Template>
                 </xcdg:AutoFilterControl>

                 <Button x:Name="clearShipCountryButton"
                         Command="xcdg:AutoFilterControl.ClearAutoFilterValues"
                         CommandTarget="{Binding ElementName=shipCountryAutoFilterControl}"
                         Content="Clear"
                         Grid.Column="2"
                         Grid.Row="0"
                         Initialized="OnClearShipCountryButtonInitialized"
                         Margin="5,2,0,2" />

                 <!--ShipCity combo box-->
                 <TextBlock Grid.Column="0"
                            Grid.Row="1"
                            Margin="5,2,5,2"
                            Text="City"
                            VerticalAlignment="Center" />

                 <xcdg:AutoFilterControl x:Name="shipCityAutoFilterControl"
                                         Grid.Column="1"
                                         Grid.Row="1"
                                         AutoFilterColumn="{Binding ElementName=grid, Path=Columns[ShipCity]}"
                                         AutoFilterContext="{Binding ElementName=grid, Path=(xcdg:DataGridControl.DataGridContext)}"
                                         Focusable="False"
                                         IsEnabled="{Binding ElementName=shipCountryAutoFilterControl, 
                                                            Path=AutoFilterContext.AutoFilterValues[ShipCountry].Count, 
                                                            Converter={StaticResource greaterThanZeroConverter},
                                                            ConverterParameter=true}"
                                         Width="Auto">
                    <xcdg:AutoFilterControl.Template>
                       <ControlTemplate TargetType="{x:Type xcdg:AutoFilterControl}">

                          <!-- We only want the City to be selectable when a Country is already selected -->
                          <ComboBox x:Name="PART_DistinctValuesHost"
                                    Grid.Column="1"
                                    Initialized="OnShipCityComboBoxInitialized"
                                    Margin="5,2,5,2"
                                    SelectionChanged="OnShipCitySelectionChanged">
                             <ComboBox.ItemTemplate>
                                <DataTemplate>
                                   <TextBlock Text="{Binding}"
                                              Padding="2,0,0,0" />
                                </DataTemplate>
                             </ComboBox.ItemTemplate>
                          </ComboBox>

                       </ControlTemplate>
                    </xcdg:AutoFilterControl.Template>
                 </xcdg:AutoFilterControl>

                 <Button Command="xcdg:AutoFilterControl.ClearAutoFilterValues"
                         CommandTarget="{Binding ElementName=shipCityAutoFilterControl}"
                         Content="Clear"
                         Grid.Column="2"
                         Grid.Row="1"
                         Margin="5,2,0,2" />

                 <!--OrderDate Month Combo Box-->
                 <TextBlock Grid.Column="0"
                            Grid.Row="2"
                            Text="Month"
                            Margin="5,2,5,2"
                            VerticalAlignment="Center" />

                 <ComboBox  ItemsSource="{Binding Source={x:Static globalization:DateTimeFormatInfo.CurrentInfo}, Path=MonthNames}"
                            Grid.Column="1"
                            Grid.Row="2"
                            Initialized="OnOrderMonthComboBoxInitialized"
                            Margin="5,2,5,2"
                            SelectionChanged="OnOrderMonthComboBoxSelectionChanged">
                    <ComboBox.ItemTemplate>
                       <DataTemplate>
                          <TextBlock Text="{Binding}"
                                     Padding="2,0,0,0" />
                       </DataTemplate>
                    </ComboBox.ItemTemplate>
                 </ComboBox>

                 <Button Click="OnClearOrderMonthButtonClick"
                         Content="Clear"
                         Grid.Column="2"
                         Grid.Row="2"
                         IsEnabled="False"
                         Initialized="OnClearMonthButtonInitialized"
                         Margin="5,2,0,2" />

              </Grid>
           </StackPanel>
        </GroupBox>

这是重要的部分:

 <xcdg:AutoFilterControl x:Name="shipCountryAutoFilterControl"
                                 Grid.Column="1"
                                 Grid.Row="0"
                                 AutoFilterColumn="{Binding ElementName=grid, Path=Columns[ShipCountry]}"
                                 AutoFilterContext="{Binding ElementName=grid, Path=(xcdg:DataGridControl.DataGridContext)}"
                                 Focusable="False"
                                 Width="Auto">
于 2011-10-19T18:48:12.147 回答
0

是的,这是可能的!查看 xceed 数据网格文档! http://doc.xceedsoft.com/products/XceedWpfDataGrid/ 很抱歉,我找不到任何直接链接,因此您必须从左侧面板导航:XCeed DataGrid for WPF->DataGrid Foundamentals->Manipulating Data->Filtering Data

于 2010-05-27T18:30:41.200 回答
0

在 DataGridControl 定义的 XAML 中查找 FilterRow 并删除。

<xcdg:DataGridControl ... > 
  <DataTemplate>
    <xcdg:FilterRow Background="Pink" />
  </DataTemplate>
</xcdg:DataGridControl> 
于 2010-09-04T19:06:59.767 回答