是否有可能在 C#中创建非平面设计? XAML 似乎没有为buttons
,dropdowns
和其他没有任何边框的控件形式实现内部阴影的功能?
答案 0 :(得分:3)
要创建非平面控件,请使用线性和径向渐变画笔填充背景。
如果您不知道如何在XAML中创建画笔,可以使用Blend来设计画笔。
对于无边框窗口,将窗口的WindowStyle设置为None。
以下是一个例子:
<Button HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="Click Me"
Foreground="White">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#FF4D4C4C" />
<GradientStop Offset="1" Color="#FF1D1D1D" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<ContentPresenter Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Button.Template>
</Button>