Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何基于默认样式创建圆边按钮样式_C#_Templates_Uwp - Fatal编程技术网

C# 如何基于默认样式创建圆边按钮样式

C# 如何基于默认样式创建圆边按钮样式,c#,templates,uwp,C#,Templates,Uwp,你好 我想知道如何使用本文中的默认样式使按钮看起来像这样: 我发现一些文章在content presenter之后添加了这一行,但它非常全面: <Ellipse Name="BorderCircle" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2"/> 谢谢, NicoTing这将在按钮中为您提供圆形边缘,您可以使用UWPCommunityToolkit进行阴影处理 不带UWPCommunityToolki

你好

我想知道如何使用本文中的默认样式使按钮看起来像这样:

我发现一些文章在content presenter之后添加了这一行,但它非常全面:

<Ellipse Name="BorderCircle" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2"/>

谢谢,

NicoTing

这将在按钮中为您提供圆形边缘,您可以使用UWPCommunityToolkit进行阴影处理

不带UWPCommunityToolkit

<Button Style="{StaticResource DefaultButtonStyle}" Content="Sign In" Background="#0086f1" Foreground="White" Height="35" Width="150"/>
XAML

<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
     <controls:DropShadowPanel BlurRadius="8"
                               ShadowOpacity="0.7"
                               OffsetX="2"
                               OffsetY="2"
                               Color="Black"
                               VerticalAlignment="Center"
                               HorizontalAlignment="Center">
        <Button Style="{StaticResource DefaultButtonStyle}" Background="#0086f1" 
                Foreground="White" Content="Sign In"  Height="35" Width="150"/>
    </controls:DropShadowPanel>
</StackPanel>

结果

<Button Style="{StaticResource DefaultButtonStyle}" Content="Sign In" Background="#0086f1" Foreground="White" Height="35" Width="150"/>

UWP社区工具包说明

<Button Style="{StaticResource DefaultButtonStyle}" Content="Sign In" Background="#0086f1" Foreground="White" Height="35" Width="150"/>
  • vs2017

  • Min SDK Windows 10.0.14393.x

  • 添加nuget包“Microsoft.Toolkit.Uwp.UI.Controls”

  • 开始的链接

  • UWP toolkit示例应用程序,用于快速查看可以使用UWPCommunityToolkit或代码执行的操作


  • 使用
    矩形

    <Grid x:Name="RootGrid"> <!-- Delete Background -->
        ....
        <Rectangle RadiusX="10" RadiusY="10" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/>
        <ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
    </Grid>
    
    
    ....
    
    你有没有研究过-是的,这就是我说的添加椭圆,但它太圆了编辑不起作用,我在默认按钮样式的contentpresenter行之后添加了它。你能在帖子中附加输出(使用我的解决方案时)吗?谢谢你的回答,但我需要的是应用默认按钮样式的半径,我在问题中的文章中的代码好的,我会更新答案,使用uwp社区工具包是使用shadow和effectsOkay的最佳方式,您能添加一个使用该工具包的示例吗?谢谢