Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Entry works with EventToCommandBehavior Custom Renderner does not

AgredoAgredo USMember ✭✭

Hello,
I created a custom renderer for an Entry to disable borders in XAML (BorderVisibility).

                    <UserControl:TextBox BorderVisibility="False"
                                     Placeholder="{Binding PasswordEntryPlaceholderText}"
                                     Grid.Row="1"
                                     Text="{Binding PasswordEntryText}"
                                     BackgroundColor="White"
                                     FontSize="Medium"
                                     IsPassword="True"
                                     Margin="0,-5,0,0">
                        <UserControl:TextBox.Behaviors>
                            <behaviorsPack:EventToCommandBehavior Command="{Binding LogInButtonCommand}" EventName="Completed"/>
                        </UserControl:TextBox.Behaviors>
                    </UserControl:TextBox>

This custom control does not work with EventToCommandBehavior. Replacing "UserControl:TextBox" with "Entry" and deleting "BorderVisibility="False"" works perfectly.
What and where I need to modify my custom renderer?

Here is more code:
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace Retailer.CustomControl
{
public class TextBox : Entry
{
public static readonly BindableProperty BorderVisibilityProperty = BindableProperty.Create("BorderVisibility", typeof(bool), typeof(TextBox), false, BindingMode.TwoWay);

    public bool BorderVisibility
    {
        get
        {
            return (bool)GetValue(BorderVisibilityProperty);
        }
        set
        {
            SetValue(BorderVisibilityProperty, value);
        }
    }

    public new event EventHandler Completed;

    public void SendComplete()
    {
        Completed?.Invoke(this, EventArgs.Empty);
    }
}

}

I have renderer for iOS, Android and UWP

Thanks in advance,

Agredo

Answers

  • jezhjezh Member, Xamarin Team Xamurai
    edited June 3

    From the code you posted, we couldn't reproduce this question.What's the code of EventToCommandBehavior and the LogInButtonCommand?

    Could you please post more code snippet about this question?

    If it is convenient for you, could you please post a basic demo so that we can test on our side?

  • AgredoAgredo USMember ✭✭
    @jezh thank you. I am not sure why this happens...
Sign In or Register to comment.