ظل WPF على عناصر التحكم في Stackpanel
-
21-09-2019 - |
سؤال
هل هناك طريقة لجعل ظل التحكم الأول في Stackpanel تظهر أعلى عنصر التحكم الثاني؟ أواجه مشكلة في هذا ، انظر إلى الصورة!
alt text http://img2.imageshack.us/img2/7073/issuef.png
عينة الكود:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Grid>
<StackPanel>
<Border Height="100" Width="100" Background="Red">
<Border.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="270" ShadowDepth="3" Opacity="1" Softness="2" />
</Border.BitmapEffect>
</Border>
<Border Height="100" Width="100" Background="blue">
</Border>
</StackPanel>
</Grid>
</Page>
المحلول
يمكنك استخدام Panel.ZIndex="0"
في كل من الحدود لتعيين ترتيب Z للعناصر مباشرة من XAML.
<StackPanel>
<Border Height="100" Width="100" Background="Red" Panel.ZIndex="1">
<Border.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="270" ShadowDepth="3" Opacity="1" Softness="2" />
</Border.BitmapEffect>
</Border>
<Border Height="100" Width="100" Background="blue" Panel.ZIndex="0">
</Border>
</StackPanel>
أو يمكنك استخدام StackPanel.SetZIndex(object, value)
إذا كنت ترغب في القيام بذلك من الكود.
لا تنتمي إلى StackOverflow