diff --git a/sample/Forms/HotUI.Forms.Sample/MainPage.cs b/sample/Forms/HotUI.Forms.Sample/MainPage.cs index 19f10e86..91b45040 100644 --- a/sample/Forms/HotUI.Forms.Sample/MainPage.cs +++ b/sample/Forms/HotUI.Forms.Sample/MainPage.cs @@ -39,7 +39,7 @@ namespace HotUI.Forms.Sample { Text = state.Text, Completed =(e)=> state.Text = e } - : new Label { TextBinding = () => $"{state.Text}: multiText" }),// Fromated Text will warn you. This should be done by TextBinding + : new Label { FormatedText = () => $"{state.Text}: multiText" }),// Fromated Text will warn you. This should be done by TextBinding new Label {Text = state.Text}, new Button{Text = "Toggle Entry/Label", OnClick = ()=> state.CanEdit = !state.CanEdit}, new Button{Text = "Update Text", OnClick = ()=>{ diff --git a/sample/HotUI.Samples/MainPage.cs b/sample/HotUI.Samples/MainPage.cs index abd43691..94f62bc3 100644 --- a/sample/HotUI.Samples/MainPage.cs +++ b/sample/HotUI.Samples/MainPage.cs @@ -36,7 +36,7 @@ namespace HotUI.Samples { Text = state.Text, Completed =(e)=> state.Text = e } - : new Label { TextBinding = () => $"{state.Text}: multiText" }),// Fromated Text will warn you. This should be done by TextBinding + : new Label { FormatedText = () => $"{state.Text}: multiText" }),// Fromated Text will warn you. This should be done by TextBinding new Label {Text = state.Text}, new Button{Text = "Toggle Entry/Label", OnClick = ()=> state.CanEdit = !state.CanEdit}, new Button{Text = "Update Text", OnClick = ()=>{ diff --git a/src/HotUI/Controls/Label.cs b/src/HotUI/Controls/Label.cs index 885b15e3..bb972923 100644 --- a/src/HotUI/Controls/Label.cs +++ b/src/HotUI/Controls/Label.cs @@ -2,25 +2,36 @@ using System.Diagnostics; namespace HotUI { public class Label : View { + public Label() + { + } + public Label(string text) + { + Text = text; + } + public Label(Func formatedText) + { + FormatedText = formatedText; + } private string text; public string Text { get => text; set => this.SetValue (State, ref text, value, ViewPropertyChanged); } - public Func TextBinding { get; set; } + public Func FormatedText { get; set; } protected override void WillUpdateView () { base.WillUpdateView (); - if (TextBinding != null) { + if (FormatedText != null) { State.StartProperty (); - var text = TextBinding.Invoke (); + var text = FormatedText.Invoke (); var props = State.EndProperty (); var propCount = props.Length; if (propCount > 0) { - State.BindingState.AddViewProperty (props, (s, o) => Text = TextBinding.Invoke ()); + State.BindingState.AddViewProperty (props, (s, o) => Text = FormatedText.Invoke ()); } Text = text; }