Issue
Here's the code that I have:
C# template class
public class PopupOKButton : Button
{
public PopupOKButton()
{
BackgroundColor = Color.Transparent;
HorizontalOptions = LayoutOptions.FillAndExpand;
Text = "OK";
SetDynamicResource(TextColorProperty, "PopUpOkColor");
VerticalOptions = LayoutOptions.End;
}
}
Where it's used:
var ok = new PopupOKButton();
ok.SetBinding(PopupOKButton.CommandProperty, "OKCmd");
ok.SetBinding(PopupOKButton.IsEnabledProperty, "OKEnabled");
Is there a way that I could change the definition of PopupOKButton to accept the binding parameters so it could be called like this:
var ok = new PopupOKButton("OKCmd", "OKEnabled" );
Solution
I've never tried it, but I assume this would work
public PopupOKButton(string Command, string Enabled) : this()
{
this.SetBinding(PopupOKButton.CommandProperty, Command);
this.SetBinding(PopupOKButton.IsEnabledProperty, Enabled);
}
public PopupOKButton()
{
BackgroundColor = Color.Transparent;
HorizontalOptions = LayoutOptions.FillAndExpand;
Text = "OK";
SetDynamicResource(TextColorProperty, "PopUpOkColor");
VerticalOptions = LayoutOptions.End;
}
Answered By - Jason
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.