Hi there
i tried to create a custom RecordSelector following a sample in the Sample Browser. I followed the sample 'xamDataGrid' --> 'Display' --> 'CheckBox in Record Selectors'.
I display an icon there, when the underlying dataItem.SomeProperty == true (with the Infragistics.Controls.Primitives.BoolToVisibilityConverter). This works fine, but the icon (or the ControlTemplate) is also displayed on the filter row (Filter Record). And is always showed there.
How can i disabled it? I tried to trigger it with a Trigger which is checking the IsDataRecord property, but this does not work. Also i want to keep the functionality, when the user clicks there to clear all the filters.
Can you give me some advise? :)
Kind regards
Hello Andreas,
You can add a relative source binding to the DataRecordPresenter’s RecordType on the visibility of the RecordSelector and set the vibility based on the type of row it is displayed in:
<local:VisibilityConverter x:Key="VisibilityConverter"/>
<Style TargetType="{x:Type igDP:RecordSelector}" BasedOn="{x:Null}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:RecordSelector}">
<CheckBox HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding Path=DataItem.IsChecked, Mode=TwoWay}" />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Visibility" Value="{Binding DataContext.RecordType, RelativeSource={RelativeSource AncestorType={x:Type igDP:DataRecordPresenter}}, Converter={StaticResource VisibilityConverter}}"/>
</Style>
public class VisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
if (value is RecordType)
RecordType rt = (RecordType) value;
if (rt == RecordType.FilterRecord)
return Visibility.Collapsed;
else
return Visibility.Visible;
}
return Binding.DoNothing;
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
Please let me know if you have any questions.
Sincerely,
Valerie
Software Developer
Infragistics Inc
Hi Valerie
I tested this solution with the code behind.. and it does not work the way i want. With this solution, the image is not shown in the filter record.. but the complete cell is not visible.. this means, that the filter cells are moved to the left, so they're not aligned with the data-cells anymore. Also the functionality to clear all filter is not available!
Regards
Hello,
If you would like to see the button to clear all record filters in the beginning of the filter row you can simply modify the style for the RecordSelector to add this to the control template and control the visibility of the items in the template based on the record type. For example:
<Style TargetType="{x:Type igDP:RecordSelector}"
BasedOn="{x:Null}">
<Grid>
<Button
x:Name="ClearButton"
HorizontalAlignment="Center"
Style="{DynamicResource {x:Static igDP:DataPresenterBase.FilterRecordClearButtonStyleKey}}"
Visibility="{TemplateBinding FilterClearButtonVisibility}"
/>
<CheckBox x:Name="HeaderCheckBox"
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFilterRecord" Value="True">
<Setter TargetName="HeaderCheckBox" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="FilterClearButtonVisibility" Value="Visible">
<Setter Property="Command" TargetName="ClearButton" Value="{x:Static igDP:DataPresenterCommands.ClearActiveRecordCellFilters}" />
</ControlTemplate.Triggers>
If there is additionally functionality currently available in the grid which you would like to maintain, I suggest that you look at the default style for the record selector and perhaps include a modified version of this style in your application. You can find the default style in C:\Program Files (x86)\Infragistics\2016.1\WPF\DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml.
This works great! Thank you for your help and the tip where to find the default style of the DataPresenter. I will take a look into it.