Q:

UWP: How to get the TaskBar Height

I am making an UWP application.My requirement is to get the size of the TaskBar programatically (This application will run on Tablets of different resolution). After following many answers on stackoverflow(which were actually more relevant to hiding/showing the taskbar), I came through this: 
How do I get the taskbar's position and size?
But this can't be done in case of UWP apps.Is there any other way to get the Height of the TaskBar.
Please Note : The TaskBar is always visible in case of my application.I don't intend to hide it
Thanks!!

A:

Well!! So after a lot of searching on internet, seeing similar answers on stackoverflow and suggestions, It seems that calculating the TaskBar height in UWP application is not so straight or simple task. However for my situation I ended up with this work around which works fine. But I will continue to find a proper approach. Assuming my screen resolution is 1600x900 ,So here is what I did:
    private void GetScreenDimension()
    {

        //To get Screen Measurements e.g. height, width, X,Y...
        ApplicationView view = ApplicationView.GetForCurrentView();
        //Getting the Window Title Bar height(In my case I get :Top=32,Bottom=860)
        double titleBarHeight = view.VisibleBounds.Top;
        //Getting the TaskBar Height
        double taskBarHeight = view.VisibleBounds.Top + (view.VisibleBounds.Top / 4);
        //Getting the workable Height of the screen ( excluding Task Bar Height)
        double availableheight = GridTimelineContent.ActualHeight - taskBarHeight;
        double availablewidth = GridTimelineContent.ActualWidth;

        if (_viewModel != null)
        {
            _viewModel.AvailableHeight = availableheight;
            _viewModel.AvailableWidth = availablewidth;
            //Getting the actual Physical height (i.e including TitleBar Height and Task Bar Height, gives 900 in my case which is what I wanted)                              
            _viewModel.ActualScreenHeight = view.VisibleBounds.Height + titleBarHeight + taskBarHeight;

            _viewModel.PageWidth = (this as Page).ActualWidth;

        }
    }

Please Note:
1) When I run the application with TaskBar Locked(visible), I get view.VisibleBounds.Height as 828.
2) When I run the application with TaskBar AutoHidden(Invisible), I get view.VisibleBounds.Height as 868.
Which gave me an idea that 900-868=32 could be Tittle Bar Height, and as I jumped from 828 to 868 after hiding the Task Bar means 868-828=40 could be the Task Bar Height.
Conclusion:
Title Bar Height = view.VisibleBounds.Top (Which is 32)
Task Bar Height = view.VisibleBounds.Top (Which is 32) + (view.VisibleBounds.Top / 4)(Which is 8);(32+8 = Total 40)
Remainning Height = view.VisibleBounds.Height (Which is 828)
If I combine the above three, I get 900 (Required Height) using this line of code:
_viewModel.ActualScreenHeight = view.VisibleBounds.Height + titleBarHeight + taskBarHeight;
I hope it's useful for others too.
Thanks!!

