Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] ContentButton #6872

Closed
KSemenenko opened this issue Jul 15, 2019 · 11 comments
Closed

[Enhancement] ContentButton #6872

KSemenenko opened this issue Jul 15, 2019 · 11 comments

Comments

@KSemenenko
Copy link
Contributor

Summary

I want to suggest an idea to make a ContentButton. I want to, like in WPF, I have the opportunity to make a button with any content inside. I understand that you can make a Grid/Frame/Stack and add a gesture recognizer to it.
But to do it every time already tired.
You also need to add a click animation.

API Changes

none

Intended Use Case

<ContetnButton Command={Binding ButtonCommand}>
    <StackLayout>
        <Label Text="1"/>
        <Label Text="2"/>
        <Image Source="image.png"/>
    </StackLayout>
</ContetnButton>
@bcaceiro
Copy link

This is, for me, one of the MUST HAVE features ASAP. The current solution of having to wrap things in a Frame / Grid to get a tap is not a cool solution. ^Most of the times we want, for example, a simple lable to be clickable. However, the label may be small, and adding the tap gesture only in the label has several problems:

  • Small hit area (which is really bad specially in mobile)
  • Not having a clicked effect, which most of the times is essencial to notify users where they clicked.

@KSemenenko
Copy link
Contributor Author

As always, I have some implementation of this component :) I will create a PR

@KSemenenko
Copy link
Contributor Author

KSemenenko commented Jul 22, 2019

For a good implementation, I need to recognize the clicks and releases of events. I can accomplish this task #3480 or make Renderers and add recognition there.
what better way to do?
I think of course that it’s better to add a gesture recognizer and not to do native Renderers.
@samhouts @PureWeen

@andreinitescu
Copy link
Contributor

Do we really need a separate ContentButton? Cant we somehow use the existing Button?

@KSemenenko
Copy link
Contributor Author

KSemenenko commented Jul 22, 2019

@andreinitescu Yes, I need a separate control. for example, if I have a complicated button. with pictures, text, something else.
I can not imagine how to do it in a normal button.
Therefore, I usually make a frame, add a gesture recognizer to it, and create the content I need.
The main problem is in the state of the buttons when the button is pressed. The main point is that the button works as in WPF, when I can put everything i need into a button content.

@KSemenenko
Copy link
Contributor Author

And the implementation can be:

  1. make renderers in which I will handle pressing and releasing events.
  2. make a gesture recognizer and then use it in this control without renderers.

@JunkyXL86
Copy link

Do we really need a separate ContentButton? Cant we somehow use the existing Button?

+1

I find it a bit disastrous the way the new IconImageSource (no replacement for Icon) has been implemented. There were historical reasons as far as I know, but I think it doesn't need to be that complicated. Text and Content (+ContentTemplate, ...) can coexist side by side.
As Xamarin.Forms is more or less a WPF clone, this would be consistent.

@KSemenenko
Copy link
Contributor Author

@andreinitescu And how do you like the idea, add the property public View Content {get; set;} to the button. And change the renderer so that if there is something in the content, then do not add a button, but add this View.

@davepruitt
Copy link

I would also love to have this ASAP. This is a feature that is sorely lacking in Xamarin Forms. Having something like this would also allow me to create custom vector graphics using the Xamarin Forms Shapes for my buttons rather than using bitmaps/images and ImageButton.

Whether it finds its home in a new control called ContentButton, or whether a new version of Button is created that allows for custom content, that does not matter to me. I'd love to see something like this:

<Button>
	<Button.Content>
		<Grid>
			...more xaml here...
		</Grid>
	</Button.Content>
</Button>

@jfversluis
Copy link
Member

Thanks for this suggestion! As Xamarin.Forms is now in maintenance mode, this will not happen anymore for Xamarin.Forms. We're only adding bugfixes and stability fixes.

If this is still important to you, make sure to check the .NET MAUI repo and see if it's already on the roadmap. If not, feel free to open a discussion to discuss a change first or open an issue with a detailed feature request. Thanks!

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2022
@IeuanWalker
Copy link

IeuanWalker commented Nov 16, 2022

If anyone still looking for this I have a XF and MAUI control that achieves this -

XF - https://github.com/IeuanWalker/Xamarin.Forms.StateButton
MAUI - https://github.com/IeuanWalker/Maui.StateButton

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants