开发者

Mac Style DockBar Functionality in WPF

I am trying to imitate the DockBar on Mac or the ObjectBar. In the process I hope to learn WPF Custom Controls and hopefully create a usable control for me and the community. So far I have this

<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>

It's a little rudimentary but I felt for starters this should be fine. The problem that I am facing are even after setting the background and the border to Transparent, the button border still shows up. On top of it I want to button region to cropped to that of the image. I would appreciate help on how this can be done.

EDIT

I found what I was looking for here


I think a wrap-panel (http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.aspx) would be a wiser choice than just limiting the buttons the user is able to set.

Also, you might as well create an style for your buttons and bind the button size to the image's size (Implement a check in the code-behind to set the max image size tho).

As for the non-transparent button borders, i dont really have a clue why that would of happen. Post a screenshot if possible ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜