범위 밖에 컨트롤이 그려지는 것을 막기 위해 ClipToBounds
속성을 이용하려 했는데 WinUI3 에는 없습니다.
어쩔 수 없습니다. 다음처럼 구현해서 쓸 수 있습니다.
public static class UIElementExtensions
{
public static readonly DependencyProperty ClipToBoundsProperty = DependencyProperty.RegisterAttached(
"ClipToBounds",
typeof(bool),
typeof(UIElementExtensions),
new PropertyMetadata(null, OnClipToBoundsPropertyChanged));
private static void OnClipToBoundsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not UIElement element)
return;
var clipToBounds = (bool)e.NewValue;
var visual = ElementCompositionPreview.GetElementVisual(element);
visual.Clip = clipToBounds ? visual.Compositor.CreateInsetClip() : null;
}
public static bool GetClipToBounds(UIElement element) => (bool)element.GetValue(ClipToBoundsProperty);
public static void SetClipToBounds(UIElement element, bool value) => element.SetValue(ClipToBoundsProperty, value);
}
<Grid Grid.Row="2" ui:UIElementExtensions.ClipToBounds="True">
<TabView Margin="0 -7 0 0">
</TabView>
</Grid>