Home Forums WPF controls Xceed DataGrid for WPF AutoFilterControl Template child event handling

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #25831 |

    Take a look at the code below, I need to put a KeyUp event for the txtCustomFilter in the custom control runtime event.

    this is the code i did in the custom DataGrid control, but it doesn’t work

    Style stAutoFilter = this.FindResource(“autoFilterControlStyle”) as Style;
    Setter sAutoFilter = stAutoFilter.Setters[0] as Setter;
    ControlTemplate ctAutoFilter = sAutoFilter.Value as ControlTemplate;
    Border b = ctAutoFilter.LoadContent() as Border;
    _txtCustomFilter = EnumVisual(b, “txtCustomFilter”) as TextBox;
    _txtCustomFilter.KeyUp += new KeyEventHandler(txtCustomFilter_KeyUp);

    <Style x:Key=”autoFilterControlStyle” TargetType=”{x:Type xceed:AutoFilterControl}”>
    <Setter Property=”Template”>
    <Border x:Name=”autoFilterControlBorder”
    Background=”{TemplateBinding Background}”
    BorderBrush=”{TemplateBinding BorderBrush}”
    BorderThickness=”{TemplateBinding BorderThickness}”>
    <RowDefinition Height=”Auto”/>
    <RowDefinition Height=”Auto”/>
    <RowDefinition Height=”*”/>

    <TextBox x:Name=”txtCustomFilter” Width=”150″ HorizontalAlignment=”Stretch” Grid.Row=”0″ >

    <Button DockPanel.Dock=”Top”
    Background=”{TemplateBinding Background}”
    Content=”Clear All Filter”
    CommandParameter=”{Binding RelativeSource={RelativeSource
    AncestorType={x:Type xceed:ColumnManagerCell}},
    Foreground=”{TemplateBinding Foreground}”/>
    <ListBox x:Name=”PART_DistinctValuesHost”
    Background=”{TemplateBinding Background}”
    Foreground=”{TemplateBinding Foreground}”
    ItemContainerStyle=”{StaticResource filterOptionCheckListItem}”
    ItemsSource=”{Binding RelativeSource={RelativeSource TemplatedParent}, Path=AutoFilterColumn.DistinctValues}”



    Imported from legacy forums. Posted by Thien Pow (had 2678 views)

    Xceed Support
    Post count: 5658

    A quick way to achieve this would be to add


    in the XAML declaration of your TextBox and define the KeyUp_EventHandler in the code behind file where your the StaticResource “autoFilterControlStyle” is defined.

    This is not the cleanest way to achieve this, but with the informations you provide, it is the easiest.

    Imported from legacy forums. Posted by Chris [Xceed] (had 347 views)

    User (Old forums)
    Post count: 23064

    Hi Christ,

    Ya I did that, but now I want to put everything in Custom control so I have to add the event handler during runtime.

    Imported from legacy forums. Posted by Thien Pow (had 3538 views)

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