【发布时间】:2011-02-08 16:10:20
【问题描述】:
我正在尝试模仿 Mac 上的 DockBar 或 ObjectBar。在此过程中,我希望学习 WPF 自定义控件,并希望为我和社区创建一个可用的控件。到目前为止我有这个
<Window x:Class="WPFMacStyleTBar.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="356" Width="577">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" x:Name="btnHome" Background="Transparent" BorderBrush="Transparent" Margin="0,0,47,0" Foreground="Transparent">
<Button.Content>
<Image Source="C:\Vikram\Projects\WPFMacStyleTBar\WPFMacStyleTBar\Images\Home.png"></Image>
</Button.Content>
</Button>
<Button Grid.Column="2" x:Name="btnGlobe" Background="Transparent" BorderBrush="Transparent" Margin="0,0,47,0" Foreground="Transparent">
<Button.Content>
<Image Source="C:\Vikram\Projects\WPFMacStyleTBar\WPFMacStyleTBar\Images\Globe.png"></Image>
</Button.Content>
</Button>
<Button Grid.Column="3" x:Name="btnNotes" Background="Transparent" BorderBrush="Transparent" Margin="0,0,49,0" Foreground="Transparent">
<Button.Content>
<Image Source="C:\Vikram\Projects\WPFMacStyleTBar\WPFMacStyleTBar\Images\Notes.png"></Image>
</Button.Content>
</Button>
</Grid>
</Grid>
这有点初级,但我觉得对于初学者来说应该没问题。我面临的问题是即使将背景和边框设置为透明后,按钮边框仍然显示。最重要的是,我想将按钮区域裁剪为图像的区域。对于如何做到这一点,我将不胜感激。
编辑
我找到了我要找的东西here
【问题讨论】:
标签: wpf wpf-controls custom-controls