【问题标题】:Make a component transparent in WIndows Phone 8.1在 WIndows Phone 8.1 中使组件透明
【发布时间】:2015-04-04 15:01:31
【问题描述】:

我在 windows phone 8.1 中是全新的,与 windows phone 8 相比,windows phone 8.1 有很多变化。我怎样才能使组件,比如按钮、网格、平铺完全像图片中的一样透明下方链接。请帮忙!!!!!!

WPF : Transparency of Window eliminated by semi-transparent brush of a contained object

【问题讨论】:

    标签: xaml windows-phone-8.1 transparency


    【解决方案1】:

    要使透明度使用背景中的 alpha 而不是不透明度,Background="#7FFFFFFF" 将 7F 降低以使其更透明。

    如果您希望控件具有透明度和相同的边框,请执行以下操作

    <Border VerticalAlignment="Top" HorizontalAlignment="Left" 
                Background="#7FFFFFFF" 
                BorderBrush="#99FFFFFF" BorderThickness="1" CornerRadius="5">
            <Grid>
                <Ellipse Width="100" Height="100"/>
            </Grid>
    </Border>
    

    这对于任何控件都是通用的,但按钮已准备好该属性但 CornerRadius,因此您可以使用此 XAML:

    <Button VerticalAlignment="Top" HorizontalAlignment="Left" 
                Background="#7FFFFFFF" 
                BorderBrush="#99FFFFFF" BorderThickness="1" >
            <Grid>
                <Ellipse Width="100" Height="100"/>
            </Grid>
    </Button>
    

    如果您需要圆角半径,您需要右键单击设计器中的按钮,编辑模板,创建一个副本,然后在模板的末尾:

    <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
    </Border>
    

    在那里改变半径和你需要的一切。

    【讨论】:

    • 我正在使用 Listview 控件。如何使 Listview 的 Tiles 透明但文本不透明。因为我将不透明度设置为 0.3,文本也变得模糊。
    • 为了使透明度使用背景中的 alpha 而不是不透明度,Background="#7FFFFFFF" 降低 7F 以使其更透明。
    • 顺便问一下,我怎样才能为底部应用栏做同样的事情?
    • 在这种情况下,更改不透明度不会影响内部控件,如果您添加一些不透明度,页面将获得完整大小,所以请注意这一点,如果我没记错的话是 48px
    • 我正在尝试为 Flyout Stackpanel 做同样的事情,但它不起作用。有什么想法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多