对于今年的 .NET 项目,我们必须在 Silverlight 中创建一个网站。
现在我已经很好地利用了网格,制作了网格行和列,但是我已经到了必须创建导航按钮的部分了。
所以我决定采用以下按钮外观:
现在,当我向项目添加按钮并为其提供该图像的背景时, 这种情况发生了。
我已经研究过创建图像按钮的其他方法,但这些方法涉及使用堆栈面板将图像放入按钮内。我试过了,看起来真的很糟糕。
这是按钮生成的代码:
<按钮内容=“按钮”高度=“40”名称=“按钮1”宽度=“125”>
<按钮.背景>
我不知道这里发生了什么,我希望有人可以帮助我。
谢谢,托马斯
For our .NET project this year we have to create a website in Silverlight.
Now I have been getting along nicely utilizing the grid, making gridrows and colums, but I have got to the part where I have to create navigation buttons.
So I decided to go for the following look of the buttons:
Now, when I add a button to my project and I give it the background of that image, this happens.
I have looked at other methods to create an image button but those involve putting an image INSIDE the button using a stackpanel. I tried that and it looks really bad.
This is the code the button generated:
<Button Content="Button" Height="40" Name="button1" Width="125">
<Button.Background>
<ImageBrush ImageSource="/OndernemersAward;component/Images/button.png" Stretch="Fill" />
</Button.Background>
</Button>
I don't know what's going on here and I hope somebody can help me.
Thanks, Thomas
发布评论
评论(2)
我最终通过使用混合解决了这个问题。我创建了一个图像,那里有一个可以将图像转换为按钮的控件。
I ultimately solved this by using blent. I created an image and there is a control there that can transform the image to a button.
将图像放入按钮内是最好的方法。您可以在按钮内放置一个图像,也可以在其中放置一个 StackPanel 并按照您认为合适的方式排列其他内容。您还可以去掉按钮上的边框和背景画笔,这样它就只是您的图像而没有其他内容。尝试以下代码:
这将创建一个按钮,该按钮只是您的图像,没有其他边框或颜色。您可以根据需要调整其他设置。请注意,为了使用图像作为按钮,您必须删除
Content
标记,因为Putting an image inside the button is the best way to go. You can just have an image inside a button, or you could put a
StackPanel
inside and arrange other content as you see fit. You can also get rid of the border and background brushes on the button so that it is just your image and nothing else. Try this code:That will make a button that is just your image with no other borders, or colors. You can tweak the other settings as you see fit. Note that in order to use the image as the button, you have to delete the
Content
tag, since the inside of the<Button>
takes the place of it.