[英]Button how to remove border
我對dat wpf按鈕有疑問。 在我的應用程序中,我有一些示例代碼
<Button x:Name="SukaKnopka" VerticalAlignment="Top" HorizontalAlignment="Right" Background="Black" MaxHeight="20" MaxWidth="20" BorderBrush="Black">
<Image Source="ButtonsImages/close_btn.png" Stretch="Fill"/>
</Button>
一切正常,但此按鈕周圍有一些小邊框=(我嘗試過BorderBrush="{x:Null}"
但該邊框再次出現。(如果MouseOver突出顯示此邊框)
據我了解,許多WPF控件的樣式已完全定義。 因此,即使您在Button
上指定了不同的邊框,例如; Button
的現有樣式將覆蓋您指定的任何樣式。 為了克服這個問題,您必須創建一個ControlTemplate
。
<Button>
<Button.Resources>
<Style TargetType="Border">
<Setter Property="BorderThickness" Value="0" />
</Style>
</Button.Resources>
</Button>
這應該可以解決問題。 它將把每個BorderThickness或按鈕內的每個Border設置為0。
slade是正確的,請嘗試修改您必須具有的外觀,如下所示,它應該可以為您提供所需的東西。
<Button x:Name="SukaKnopka" VerticalAlignment="Top" HorizontalAlignment="Right" Background="Black" MaxHeight="20" MaxWidth="20" BorderBrush="Black">
<Button.Template>
<ControlTemplate>
<Image Source="ButtonsImages/close_btn.png" Stretch="Fill"/>
</ControlTemplate>
</Button.Template>
</Button>
自從我做過任何“真正的” WPF以來已經有一段時間了,但是
BorderThickness="0,0,0,0"
工作?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.