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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    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”>
    <Setter.Value>
    <ControlTemplate>
    <Border x:Name=”autoFilterControlBorder”
    Background=”{TemplateBinding Background}”
    BorderBrush=”{TemplateBinding BorderBrush}”
    BorderThickness=”{TemplateBinding BorderThickness}”>
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition Height=”Auto”/>
    <RowDefinition Height=”Auto”/>
    <RowDefinition Height=”*”/>
    </Grid.RowDefinitions>

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

    <Button DockPanel.Dock=”Top”
    Grid.Row=”1″
    MinHeight=”24″
    Background=”{TemplateBinding Background}”
    Content=”Clear All Filter”
    Command=”xceed:AutoFilterControl.ClearAutoFilterValues”
    CommandParameter=”{Binding RelativeSource={RelativeSource
    AncestorType={x:Type xceed:ColumnManagerCell}},
    Path=ParentColumn}”
    Foreground=”{TemplateBinding Foreground}”/>
    <ListBox x:Name=”PART_DistinctValuesHost”
    Grid.Row=”2″
    Background=”{TemplateBinding Background}”
    Foreground=”{TemplateBinding Foreground}”
    BorderThickness=”0″
    ItemContainerStyle=”{StaticResource filterOptionCheckListItem}”
    ItemsSource=”{Binding RelativeSource={RelativeSource TemplatedParent}, Path=AutoFilterColumn.DistinctValues}”
    SelectionMode=”Multiple”/>

    </Grid>
    </Border>

    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>

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

    Xceed Support
    Member
    Post count: 5658

    A quick way to achieve this would be to add

    KeyUp=”KeyUp_EventHandler”

    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)
    Member
    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.