xamarin形式的带有2个图像和文本的按钮

问题描述:

我正在尝试创建一个带有两个图像的按钮.一个在左侧,一个在右侧,文本居中.搜索后,我只得到了一个带有图像的按钮,因此我想知道是否可以像上面在xamarin中所述创建按钮.

I am trying to create a button with two images on it. One at left side and one at right side and text in center. After searching I got a button with image only so I wanted to know if it is posible to create a button as I described above in xamarin?

我正在尝试创建这样的按钮,并且我也想更改按钮上的箭头图像,即单击向上箭头和向下箭头.在xamarin中创建这样的按钮是否可能,或者我应该考虑其他选择吗?

I am trying to create button like this and also I want to change arrow image on the button click to up arrow and down arrow. Is it posible in xamarin to create button like this or should I think about another option any idea?

您不能直接使用Xamarin Forms中的按钮执行此操作,因为它尚不支持图像.

You can't directly do this with the Button from Xamarin Forms as it doesn't support images yet.

根据您的要求,您可以创建一个水平的堆栈布局,并向其中添加图像和标签.还要设置背景色,使其看起来像一个按钮.要使其像按钮一样工作,请将手势识别器添加到堆栈布局中并添加点击手势.如果使用的是MVVM,则可以处理事件以进行点击或绑定.

From your requirement what you can do is create a horizontal stacklayout and add the images and a label to it. Also set a background color so that it would look like a button. To make it work like a button, add a Gesture recognizer to the stack layout and add the tap gesture. You can handle the event for tapping or bind it via command if you are using MVVM.