文章出處

在實際開發過程中,有時候要設置一個無邊框的按鈕,或者無邊框的透明按鈕。

 按鈕效果如下:

 

1、當你應用telerik組件中的Button時,這個直接就可以設置 

telerik:StyleManager.Theme="Windows8"時,這個附加屬性已經對Button的ControlTemplate進行了樣式的設置

<telerik:RadButton x:Name="BtnClose" ToolTip="關閉"  BorderThickness="0" Background="Transparent" telerik:StyleManager.Theme="Windows8">
        <Image Source="..\..\Images\關閉.png" Height="16"/>
</telerik:RadButton>

2、應用本地WPF的Button

單純的設置borderbrush和borderThinkness是沒有用的,只能重新定義控件模板。

 

<Button x:Name="BtnClose" ToolTip="關閉" Background="Transparent">
     <Button.Template>
             <ControlTemplate TargetType="{x:Type Button}">
                  <Grid>
                       <Rectangle Height="15" Width="15">
                            <Rectangle.Fill>
                                <ImageBrush ImageSource="../Images/關閉.png"></ImageBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"></ContentPresenter>
                    </Grid>
                </ControlTemplate>
       /Button.Template>  
</Button>

 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()