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

Taskbar Icon not moving to next monitor

1 Answer 110 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Iron
Iron
Iron
Marco asked on 12 Feb 2021, 11:40 PM

Hello,

i was in correspondence with Martin Ivanov and we worked out some information i want to share.

Situation: Multi-Monitor-Environment with Taskbars on every monitor. Docking with floating panes and taskbar icon like: https://github.com/telerik/xaml-sdk/tree/master/Docking/FloatingPaneTaskbarIcons 

Problem: when moving a ToolWindow to the next monitor the taskbar icon stays on the monitor it was created.

Reason: some native WPF window behavior

Workaround: Create a custom ToolWindow and "refresh" icon when window is moved to an other monitor:

public class CustomToolWindow : ToolWindow
{
    private Screen _startMonitor;       
     
    public CustomToolWindow()
    {
        LayoutChangeEnded += Window_LayoutChangeEnded;
        LayoutChangeStarted += Window_LayoutChangeStarted;
    }
     
    private Screen FindMonitor()
    {
        var yCenter = Top + (Height / 2);
        var xCenter = Left + (Width / 2);
 
        return Screen.AllScreens.FirstOrDefault(x =>
            x.Bounds.Top < yCenter && (x.Bounds.Top + x.Bounds.Height > yCenter)
            && x.Bounds.Left < xCenter && (x.Bounds.Left + x.Bounds.Width > xCenter)
        );
    }
     
    private void Window_LayoutChangeStarted(object sender, EventArgs e)
    {
        _startMonitor = FindMonitor();
    }
 
    private void Window_LayoutChangeEnded(object sender, EventArgs e)
    {
        if (!Equals(_startMonitor, FindMonitor()))
        {
            RadWindowInteropHelper.SetShowInTaskbar(sender as ToolWindow, false);
            RadWindowInteropHelper.SetShowInTaskbar(sender as ToolWindow, true);
        }
    }
}

I hope this helps. If someone optimize the code and find a solution to prevent the flickering on "refresh" please share it!

regards marco

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 16 Feb 2021, 11:00 AM

Hello Marco,

That is some great description. Thank you for sharing it. As a small gesture of gratitude for taking your time and preparing this information you can find your Telerik points updated.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Docking
Asked by
Marco
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or