This is a migrated thread and some comments may be shown as answers.

Custom Filtering Control Closes When Clicking on Filter Control.

4 Answers 158 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Timothy
Top achievements
Rank 1
Timothy asked on 07 Jul 2017, 11:10 AM

Hi I am building a custom Filtering Control which allows users to resize the control. Interacting with the thumbs to resize is working but,I have noticed that when i click on the main  FilteringControl the whole Custom control will closes which means i can't filter my data :( .  How can i stop this from occurring? Thanks in advance.

<UserControl x:Class="MyControls.Views.ResizableFilteringControl.ResizableFilteringControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="500" >
    <UserControl.Resources>

    </UserControl.Resources>

    <Grid>
        <StackPanel Margin="18" Background="White">
          
        <telerik:FilteringControl Name="FilteringControl"></telerik:FilteringControl>
            <Grid>
                <Thumb Name="SouthEastThumb"
                   HorizontalAlignment="Left" 
                   VerticalAlignment="Bottom" 
                   Width="16" Height="16" 
                   MouseEnter="OnMouseEnter"
                   DragStarted="OnDragStarted" 
                   DragDelta="OnDragDelta" 
                   DragCompleted="OnDragCompleted"/>
                <Thumb Name="SouthWestThumb"
                   HorizontalAlignment="Right" 
                   VerticalAlignment="Bottom" 
                   Width="16" Height="16" 
                   MouseEnter="OnMouseEnter"
                   DragStarted="OnDragStarted" 
                   DragDelta="OnDragDelta" 
                   DragCompleted="OnDragCompleted"/>
            </Grid>  
        
        
        </StackPanel>
    </Grid>
</UserControl>

 

 

Code behind:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Core.Native;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
using GridViewColumn = Telerik.Windows.Controls.GridViewColumn;


namespace MyControls.Views.ResizableFilteringControl
{
    /// <summary>
    /// Interaction logic for ResizableFilteringControl.xaml
    /// </summary>
    public partial class ResizableFilteringControl : IFilteringControl
    {
        //TODO fix issue with control not remiaing open when i click on the FilteringControl.
        //TODO add style to Thumbs.
        public ResizableFilteringControl()
        {
            InitializeComponent();
        }

        public void Prepare(GridViewColumn columnToPrepare)
        {
            this.FilteringControl?.Prepare(columnToPrepare);
         
        }

        public bool IsActive
        {
            get { return (bool)GetValue(IsActiveProperty); }
            set { SetValue(IsActiveProperty, value); }
        }

        /// <summary>
        /// Identifies the <see cref="IsActive"/> dependency property.
        /// </summary>
        public static readonly DependencyProperty IsActiveProperty =
            DependencyProperty.Register(
                "IsActive",
                typeof(bool),
                typeof(ResizableFilteringControl),
                new System.Windows.PropertyMetadata(false));

        private void OnDragStarted(object sender, DragStartedEventArgs e)

        {
            SetCursor(sender);
        }

        private void OnDragDelta(object sender, DragDeltaEventArgs e)

        {
            //TODO make resize to left.
            
            var yadjust = FilteringControl.RenderSize.Height + e.VerticalChange;
            var xadjust = this.FilteringControl.RenderSize.Width + e.HorizontalChange;

            if (IsResizeAllowed(xadjust, yadjust))

            {
                this.FilteringControl.Width = xadjust;
                this.FilteringControl.Height = yadjust;
            }
        }

        private static bool IsResizeAllowed(double xadjust, double yadjust)
        {
            //TODO let consumer specify these values so they are not hard coded.
            return (xadjust >= 50 && yadjust >= 50) &&
                   (xadjust <= 800 && yadjust <= 800);
        }

        private void OnDragCompleted(object sender, DragCompletedEventArgs e)
        {
            var t = (Thumb)sender;
            t.Cursor = null;
        }
        
        private void OnMouseEnter(object sender, MouseEventArgs e)
        {
            SetCursor(sender);
        }

        private static void SetCursor(object sender)
        {
            var thumb =  sender as Thumb;
            if (thumb != null)
            {
                if (thumb.Name == "SouthWestThumb")
                {
                    thumb.Cursor = Cursors.SizeNWSE;
                }
                else if (thumb.Name == "SouthEastThumb")
                {
                    thumb.Cursor = Cursors.SizeNESW;
                }
                else
                {
                    thumb.Cursor = null;
                }
            }         
        }
    }
}

4 Answers, 1 is accepted

Sort by
0
Timothy
Top achievements
Rank 1
answered on 12 Jul 2017, 09:30 AM
I have given up on this approach and created a new style template which has produced better results. 
0
Christian
Top achievements
Rank 1
answered on 16 Jul 2019, 11:06 PM

Having the same problem:

1. Implemented custom :IFilteringControl

2. Override template of FilteringControl

   <Style TargetType="{x:Type telerik:FilteringControl}">
       <Setter Property="Template">
           <Setter.Value>
               <ControlTemplate>
                   <my:CustomFilterControl/>
               </ControlTemplate>
           </Setter.Value>
       </Setter>
   </Style>

 

PROBLEM: The custom filterControl is getting shown, but the filtering-popUp closes immediately if click happens anywhere inside the custom-filteringControl

 

If there is a button inside the custom-filteringControl:

- click-event handler is never invoked

- previewmouse-leftButtonDown event handler IS invoked, but popUp still closes immediately after that, even if e.handled is set to true

 

Any help appreciated .. could not find any workaround and we need a custom filteringControl.

Thanks in advance

0
Martin Ivanov
Telerik team
answered on 19 Jul 2019, 02:48 PM
Hello Christian,

There were a similar issue which should be fixed in the latest release. Can you please try the latest dlls and see if this helps? If not, I would recommend you to open a new support ticket from your telerik.com account and attach a runnable project showing the issue there.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Christian
Top achievements
Rank 1
answered on 23 Jul 2019, 02:26 PM

Hello Martin,

Upgrade to Version 2019.2.618 did not resolve the problem. I opened a new support-ticket.

Regards,

Christian

Tags
GridView
Asked by
Timothy
Top achievements
Rank 1
Answers by
Timothy
Top achievements
Rank 1
Christian
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or