8 Replies - 366 Views - Last Post: 19 February 2019 - 10:11 AM Rate Topic: -----

#1 ScottinTexas   User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 296
  • Joined: 13-March 12

"Auto Hide Panels?"

Posted 11 February 2019 - 06:31 PM

So I want to have panels like Visual Studio that you can pin open or let auto hide. Like the Test Explorer or the Properties panels. I look all over for Auto Hide Panels WPF C# MVVM. I find a lot of a commercial product and several things from 2005 or 2006. Of course, the panels would be home to controls that have to be bound to properties in a view model. So does anyone know of an example or some sort of discussion on the topic that is more modern that DOS? Do I have to take a class in Google Searching Terms?

Signed "Frustrated in Texas" or "WTF is this page?" or "Can't be that difficult!"

EDIT: Maybe I should use Bing!?

This post has been edited by ScottinTexas: 11 February 2019 - 06:33 PM


Is This A Good Question/Topic? 0
  • +

Replies To: "Auto Hide Panels?"

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14992
  • View blog
  • Posts: 59,853
  • Joined: 12-June 08

Re: "Auto Hide Panels?"

Posted 11 February 2019 - 06:46 PM

I remember infragistics had a pinnable panel that autohides... if that helps.
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6877
  • View blog
  • Posts: 23,322
  • Joined: 05-May 12

Re: "Auto Hide Panels?"

Posted 11 February 2019 - 07:04 PM

You can likely use the code and concepts from Sliding Panel in WPF as a starting point. Instead of depending on the click event to trigger the slide and hide, you'll likely want to bind to a Visible property in the view model that determine whether the panel should be visible or not. It'll be up to you to determine what conditions will set the Visible property.
Was This Post Helpful? 0
  • +
  • -

#4 ScottinTexas   User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 296
  • Joined: 13-March 12

Re: "Auto Hide Panels?"

Posted 13 February 2019 - 05:26 AM

Thank you, both, for your replies. I checked out the answers. I ll try the sliding panel idea, but it is not really what I want. But it's a start. Thanks again.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,046
  • Joined: 12-December 12

Re: "Auto Hide Panels?"

Posted 13 February 2019 - 06:01 AM

If the main features you are looking for are to pin (or dock somewhere) and autohide, why not try to roll your own? ;). Start by exploring available controls and their behaviours.
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6877
  • View blog
  • Posts: 23,322
  • Joined: 05-May 12

Re: "Auto Hide Panels?"

Posted 13 February 2019 - 06:10 AM

Basically, implementing auto-hide is like implementing a tooltip from scratch:
- if the object is visible, hit test to see if mouse is hovering over the object
- if in object, keep object visible
- if not in object create timer for hide delay
- when timer fires and mouse not over object, hide the object
- if object is not visible, but mouse is over hotspot, create timer for show delay
- when timer fires and mouse is still in hotspot, show the object
Was This Post Helpful? 0
  • +
  • -

#7 ScottinTexas   User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 296
  • Joined: 13-March 12

Re: "Auto Hide Panels?"

Posted 18 February 2019 - 06:59 AM

I am working on rolling my own. I have seen a few sliding panel examples and I am trying to get a headered content control to open or close in a similar fashion. But this is one of those "fun projects" to work on when my brain rebels against the mundane crap I have to work on daily. So it will be slow going. If I ever have one working before a new version of WPF tools comes out with it, I will post it. I was also looking at a tab control with one tab. Seeing if the mouse was over the tab, extend the content area. When the mouse leaves it, shrink the content. Like Skydiver is saying above. The hit test. It seems like adding the pin to "turn off" hiding would not be so difficult once you have the working tab control. Using a tab control also allows me to move the tab to what ever side I want. I have scribbled my notes then got assigned another project. I could move faster if I learned to use Blend, I'm sure. Now that I am discussing this, I think I'll take some time this afternoon to look at it again. I just have to get a few things done first.

Thanks for the input!
Was This Post Helpful? 0
  • +
  • -

#8 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: "Auto Hide Panels?"

Posted 18 February 2019 - 05:04 PM

I whipped this up real quick... probably needs some tweaks and debug. I tried to get it working with a binding context and for some reason it wasn't working. You should modify for a
DataContext


        public class FrameCoordinates
        {
            public bool _frameHover = false;
        }

        DispatcherTimer timer = new DispatcherTimer();

        public void DispatcherTimerSample(bool start)
        {
            InitializeComponent();

            timer.Interval = TimeSpan.FromSeconds(1); // <<< this is really slow??
            timer.Tick += timer_Tick;
            if (start == true)
            {
                timer.Start();
            }
            else
            {
                timer.Stop();
            }
        }
        FrameCoordinates _frame = new FrameCoordinates();

        Thickness _frameParam = new Thickness();

        Thickness _tabParam = new Thickness();

        double xPadDouble = -132;

        double xTabDouble = -100;

        void timer_Tick(object sender, EventArgs e)
        {
            //-132, 0
            //-32, 100
            
            if (xPadDouble <= 0)
            {
                if (_frame._frameHover == true)
                {
                    if (xPadDouble == 0)
                    {
                        //nothing
                    }
                    else
                    {
                        xPadDouble = xPadDouble + 1;
                        xTabDouble = xTabDouble + 1;
                    }
                }
            }
            if (xPadDouble >= -132)
            {
                if (_frame._frameHover == false)
                {
                    if (xPadDouble == -132)
                    {
                        DispatcherTimerSample(false);
                    }
                    else
                    {
                        xPadDouble = xPadDouble - 1;
                        xTabDouble = xTabDouble - 1;
                    }
                }
            }

            _frameParam.Bottom = 0;

            _frameParam.Left = xPadDouble;

            _frameParam.Top = 0;

            _frameParam.Right = 0;

            dockPanel.Margin = _frameParam;

            _tabParam.Bottom = 0;

            _tabParam.Left = xTabDouble;

            _tabParam.Top = 41;

            _tabParam.Right = 0;

            tabControl.Margin = _tabParam;
        }



        private void TabControl_MouseEnter(object sender, MouseEventArgs e)
        {
            _frame._frameHover = true;
            DispatcherTimerSample(true);

            
        }

        private void TabControl_MouseLeave(object sender, MouseEventArgs e)
        {
            _frame._frameHover = false;
        }

        private void DockPanel_MouseEnter(object sender, MouseEventArgs e)
        {
            _frame._frameHover = true;
            DispatcherTimerSample(true);
        }

        private void DockPanel_MouseLeave(object sender, MouseEventArgs e)
        {
            _frame._frameHover = false;
        }





also it will move really slow... so you need to figure out how to decrease the timer interval. I'm leaving for the night. I'll modify it tomorrow.

I'm also not sure if I can use ++ with a double or not??? I know.. n00bish lol but if so that can be simplified a tad on the pos modifiers

it uses a dock panel that starts @ -132 in thickness and stops @ 0 and a tab control that starts @ -32 in left pad and ends in 100. I think the dock panel is about 132 px so you will need to modify that as-well.
Was This Post Helpful? 0
  • +
  • -

#9 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: "Auto Hide Panels?"

Posted 19 February 2019 - 10:11 AM

Here are the fixed codes, sorry I was working on a ton of stuff and on my way out the door yesterday.

C#:

        public class FrameCoordinates
        {
            public bool _frameHover = false;
        }

        DispatcherTimer timer = new DispatcherTimer();

        public void DispatcherTimerSample(bool start)
        {

            timer.Interval = TimeSpan.FromSeconds(.01);
            timer.Tick += timer_Tick;
            if (start == true)
            {
                timer.Start();
            }
            else
            {
                timer.Stop();
            }
        }
        FrameCoordinates _frame = new FrameCoordinates();

        Thickness _frameParam = new Thickness();

        Thickness _tabParam = new Thickness();

        double xPadDouble = -132;

        double xTabDouble = -32;

        void timer_Tick(object sender, EventArgs e)
        {
            //-132, 0
            //-32, 100
            

                if (_frame._frameHover == true)
               {
                    if (xPadDouble == 0)
                    {
                        //nothing
                    }
                    else
                    {
                        xPadDouble = xPadDouble + 1;
                        xTabDouble = xTabDouble + 1;
                    }
                }
                
                if (_frame._frameHover == false)
                {
                    if (xPadDouble == -132)
                    {
                        DispatcherTimerSample(false);
                    }
                    else
                    {
                        xPadDouble = xPadDouble - 1;
                        xTabDouble = xTabDouble - 1;
                    }
                }
            
    
            _frameParam.Bottom = 0;

            _frameParam.Left = xPadDouble;

            _frameParam.Top = 0;

            _frameParam.Right = 0;

            dockPanel.Margin = _frameParam;

            _tabParam.Bottom = 0;

            _tabParam.Left = xTabDouble;

            _tabParam.Top = 41;

            _tabParam.Right = 0;

            tabControl.Margin = _tabParam;
        }



        private void TabControl_MouseEnter(object sender, MouseEventArgs e)
        {
            _frame._frameHover = true;
            DispatcherTimerSample(true);

            
        }

        private void TabControl_MouseLeave(object sender, MouseEventArgs e)
        {
            _frame._frameHover = false;
        }

        private void DockPanel_MouseEnter(object sender, MouseEventArgs e)
        {
            _frame._frameHover = true;
            
            DispatcherTimerSample(true);
        }

        private void DockPanel_MouseLeave(object sender, MouseEventArgs e)
        {
            _frame._frameHover = false;
        }






XAML:
        <TabControl x:Name="tabControl" HorizontalAlignment="Left" Height="28" Margin="-32,41,0,0" VerticalAlignment="Top" Width="100" RenderTransformOrigin="0.5,0.5" MouseEnter="TabControl_MouseEnter" MouseLeave="TabControl_MouseLeave">
            <TabControl.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform Angle="90"/>
                    <TranslateTransform/>
                </TransformGroup>
            </TabControl.RenderTransform>
            <TabItem Header="TabItem" Margin="0,0,-4,-4"/>
        </TabControl>


        <DockPanel x:Name="dockPanel" HorizontalAlignment="Left" Height="419" LastChildFill="False" VerticalAlignment="Top" Width="132" Background="White" Margin="-132,0,0,0" MouseEnter="DockPanel_MouseEnter" MouseLeave="DockPanel_MouseLeave"/>




and like I said you should convert that to a binding context not push the UI
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1