如何制作具有多个内容值的按钮? [英] How can I make a Button with multiple content values?

查看:22
本文介绍了如何制作具有多个内容值的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是制作一个具有两个 Content 值的按钮.

My goal is to make a Button that has two Content values.

将拼字游戏图块想象成一个按钮:它的中心是一个大字母,右下角是一个小数字.这就是我要的效果.

Imagine a Scrabble tile as a button: it has the large letter in the center and a small number in the lower right. This is the effect I am going for.

我制作了一个按钮,其中有两个 ContentPresenter 对象,并且我为每个 ContentPresenter 指定了不同的样式.但是,我还没有找到一种方法来给每个演示者一个单独的值(即,如果我将按钮的内容设置为X",那么两个 ContentPresenter 都会显示X",尽管样式不同).

I made a button that has two ContentPresenter objects in it, and I have given each of the ContentPresenters a different style. However, I have not found a way to give each of the presenters a separate value (ie, if I set the Content of the button to "X" then both ContentPresenters show "X", albeit in different styles).

我怎样才能实现我的目标?我猜我的方法是完全错误的....

How can I achieve my objective? I'm guessing my approach is completely wrong....

推荐答案

呸...我想我现在知道该做什么了.我应该制作自己的控件而不是修改按钮.如果我在 WinForms 中工作,这对我来说是显而易见的,但出于某种原因,所有这些 Xaml 都让我变得愚蠢.

Bah... I think I know what to do now. I should be making my own control rather than modifying a Button. This would have been obvious to me had I been working in WinForms, but for some reason all this Xaml is making me stupid.

这篇关于如何制作具有多个内容值的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆