Fix Entry
This commit is contained in:
parent
e085f236b6
commit
786343a8ae
|
@ -7,6 +7,7 @@ using Xamarin.Forms.Internals;
|
|||
[assembly: Dependency (typeof (ResourcesProvider))]
|
||||
[assembly: ExportRenderer (typeof (BoxView), typeof (BoxRenderer))]
|
||||
[assembly: ExportRenderer (typeof (Button), typeof (ButtonRenderer))]
|
||||
[assembly: ExportRenderer (typeof (Entry), typeof (EntryRenderer))]
|
||||
[assembly: ExportRenderer (typeof (Label), typeof (LabelRenderer))]
|
||||
|
||||
namespace Ooui.Forms
|
||||
|
|
|
@ -13,17 +13,15 @@ namespace Ooui.Forms.Renderers
|
|||
|
||||
static Size initialSize = Size.Zero;
|
||||
|
||||
public EntryRenderer ()
|
||||
{
|
||||
}
|
||||
IElementController ElementController => Element as IElementController;
|
||||
|
||||
public override SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint)
|
||||
{
|
||||
return base.GetDesiredSize (widthConstraint, heightConstraint);
|
||||
var size = Element.Text.MeasureSize (Element.FontFamily, Element.FontSize, Element.FontAttributes);
|
||||
size = new Size (size.Width, size.Height * 1.428 + 14);
|
||||
return new SizeRequest (size, size);
|
||||
}
|
||||
|
||||
IElementController ElementController => Element as IElementController;
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
|
@ -53,6 +51,10 @@ namespace Ooui.Forms.Renderers
|
|||
var textField = new Ooui.Input (InputType.Text);
|
||||
SetNativeControl (textField);
|
||||
|
||||
Debug.Assert (Control != null, "Control != null");
|
||||
|
||||
textField.ClassName = "form-control";
|
||||
|
||||
_defaultTextColor = Colors.Black;
|
||||
|
||||
textField.Inputted += OnEditingChanged;
|
||||
|
@ -154,14 +156,14 @@ namespace Ooui.Forms.Renderers
|
|||
|
||||
void UpdatePlaceholder ()
|
||||
{
|
||||
Control.Placeholder = Element.Placeholder;
|
||||
Control.Placeholder = Element.Placeholder ?? "";
|
||||
}
|
||||
|
||||
void UpdateText ()
|
||||
{
|
||||
// ReSharper disable once RedundantCheckBeforeAssignment
|
||||
if (Control.Text != Element.Text)
|
||||
Control.Text = Element.Text;
|
||||
if (Control.Value != Element.Text)
|
||||
Control.Value = Element.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
x:Class="ButtonXaml.ButtonXamlPage">
|
||||
|
||||
<StackLayout Padding="20">
|
||||
<Label Text="Welcome to Xamarin.Forms!"/>
|
||||
<Label x:Name="LabelCount" Text="Click Count: 0"/>
|
||||
<Label Text="Welcome to Xamarin.Forms!" FontSize="32" FontAttributes="Bold" />
|
||||
<Entry x:Name="LabelCount" Text="Click Count: 0"/>
|
||||
<Button Text="Tap for click count!"
|
||||
Clicked="OnButtonClicked" />
|
||||
</StackLayout>
|
||||
|
|
Loading…
Reference in New Issue