Ich starte den Debugger. Alle funktionieren feine Bildunterschriften und TabvieItem sind nicht draggbar
Aber wenn ich mein Fenster maximiere, kann ich mich mit dem TabvieItem maximieren und den Schäbchen, der das TapvieItem aus dem Fenster addiere, das Schaltwechsel addiere. Aber das möchte ich nicht < /p>
Mein TabviewControl VisualTree < /p>
Code: Select all
< /code>
My UserWindow (MainWindow) VisualTree < /p>
private void MyUserWindow_SizeChanged(object sender, WindowSizeChangedEventArgs args)
{
this.MyCaptionsRegion.OnWindowStateChanged();
if (this.MyTitleRegion.XamlRoot != null)
{ SetRegionsForCustomTitleBar(); }
}
internal void SetRegionsForCustomTitleBar()
{
double scale = this.MyTitleRegion.XamlRoot.RasterizationScale;
// Set the Width of TitleBar
SetTitleBarWidth(this.AppWindow, this.MyTitleRegion, scale);
// Set the draggable Area/Region of TitleBar
SetDraggableArea(this.AppWindow, this.MyTabView, scale);
// Set the non-draggable Area/Region of CaptionsButton
SetNonDraggableRegion(this.AppWindow, this.MyCaptionsRegion, scale);
}
private void SetTitleBarWidth(AppWindow myAppWindow, MyTitleRegionControl myTitleRegion, double scale)
{
myTitleRegion.GetHeaderDefinition().Width = new GridLength(myAppWindow.TitleBar.LeftInset / scale);
myTitleRegion.GetFooterDefinition().Width = new GridLength(myAppWindow.TitleBar.RightInset / scale);
}
private void SetDraggableArea(AppWindow myAppWindow, MyTabViewControl myTabView, double scale)
{
Border myCustomDragRegion = myTabView.GetCustomDragRegion();
GeneralTransform customDragRegionTransform = myCustomDragRegion.TransformToVisual(null);
Rect customDragRegionBounds = customDragRegionTransform.TransformBounds(new Rect(0, 0, myCustomDragRegion.ActualWidth, myCustomDragRegion.ActualHeight));
RectInt32 customDragRegionRect = GetRect(customDragRegionBounds, scale);
Trace.WriteLine($"[SetDraggableArea] Bounds: X={customDragRegionBounds.X}, Y={customDragRegionBounds.Y}, W={customDragRegionBounds.Width}, H={customDragRegionBounds.Height}");
Trace.WriteLine($"[SetDraggableArea] Scaled Rect: X={customDragRegionRect.X}, Y={customDragRegionRect.Y}, W={customDragRegionRect.Width}, H={customDragRegionRect.Height}");
myAppWindow.TitleBar.SetDragRectangles(GetRectArray(customDragRegionRect));
}
private void SetNonDraggableRegion(AppWindow myAppWindow, MyCaptionsRegionControl myCaptionsRegion, double scale)
{
GeneralTransform captionsRegionTransform = myCaptionsRegion.TransformToVisual(null);
Rect captionsRegionBounds = captionsRegionTransform.TransformBounds(new Rect(0, 0, myCaptionsRegion.ActualWidth, myCaptionsRegion.ActualHeight));
RectInt32 captionsRegionRect = GetRect(captionsRegionBounds, scale);
InputNonClientPointerSource nonClientInputSrc = InputNonClientPointerSource.GetForWindowId(myAppWindow.Id);
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, GetRectArray(captionsRegionRect));
}
private RectInt32 GetRect(Rect bounds, double scale)
{
return new RectInt32
(
_X: (int)Math.Round(bounds.X * scale),
_Y: (int)Math.Round(bounds.Y * scale),
_Width: (int)Math.Round(bounds.Width * scale),
_Height: (int)Math.Round(bounds.Height * scale)
);
}
private RectInt32[] GetRectArray(RectInt32 rect)
{
return new RectInt32[] { rect };
}
< /code>
i Testet auch, wenn die korrekte Größe berechnet
Start:
[setDaggablearea] Grenzen: x = 97, y = 0, w = 1327, H = 40
[setDaggableara] scaled rect: x = 97, y = 0, w = 1327, H = 40 < /p> < /p>
[SetDraggableArea] Bounds: X=97, Y=0, W=1823, H=40
[SetDraggableArea] Scaled Rect: X=97, Y=0, W=1823, H=40
After restoring back:
[SetDraggableArea] Bounds: X=97, Y=0, W=1327, H=40
[SetDaggablearea] scaled rct: x = 97, y = 0, w = 1327, H = 40 < /p>
Ich denke>