private InputMethodContext inputMethodContext = null;
private float fontSizeScale = 1.0f;
private bool hasFontSizeChangedCallback = false;
+ private bool isSettingTextInCSharp = false;
static TextEditor() { }
{
SetVisible(false);
}
+
+ TextChanged += TextEditorTextChanged;
}
internal TextEditor(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true, TextEditorStyle style = null) : base(cPtr, cMemoryOwn, style)
{
SetVisible(false);
}
- Focusable = true;
+
+ TextChanged += TextEditorTextChanged;
}
/// <summary>
}
set
{
- SetValueAndForceSendChangeSignal(TextProperty, value);
+ SetValue(TextProperty, value);
NotifyPropertyChanged();
}
}
}
}
- /// Only used by the IL of xaml, will never changed to not hidden.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override bool IsCreateByXaml
- {
- get
- {
- return base.IsCreateByXaml;
- }
- set
- {
- base.IsCreateByXaml = value;
-
- if (value == true)
- {
- this.TextChanged += (obj, e) =>
- {
- this.Text = e.TextEditor.Text;
- };
- }
- }
- }
-
/// <summary>
/// The FontSizeScale property. <br />
/// The default value is 1.0. <br />
}
}
+ TextChanged -= TextEditorTextChanged;
base.Dispose(type);
}
}
}
+ private void TextEditorTextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (!isSettingTextInCSharp)
+ {
+ EnforceNotifyBindedInstance(TextProperty);
+ }
+ }
+
internal new class Property
{
internal static readonly int TEXT = Interop.TextEditor.TextGet();
private InputMethodContext inputMethodCotext = null;
private float fontSizeScale = 1.0f;
private bool hasFontSizeChangedCallback = false;
+ private bool isSettingTextInCSharp = false;
static TextField() { }
{
SetVisible(false);
}
- Focusable = true;
+
+ TextChanged += TextFieldTextChanged;
}
internal TextField(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn, null)
{
SetVisible(false);
}
- Focusable = true;
+
+ TextChanged += TextFieldTextChanged;
}
internal TextField(TextField handle, bool shown = true) : this(Interop.TextField.NewTextField(TextField.getCPtr(handle)), true)
{
SetVisible(false);
}
+
+ TextChanged += TextFieldTextChanged;
}
internal enum ExceedPolicyType
}
set
{
- SetValueAndForceSendChangeSignal(TextProperty, value);
+ SetValue(TextProperty, value);
NotifyPropertyChanged();
}
}
}
}
- /// Only used by the IL of xaml, will never changed to not hidden.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override bool IsCreateByXaml
- {
- get
- {
- return base.IsCreateByXaml;
- }
- set
- {
- base.IsCreateByXaml = value;
-
- if (value == true)
- {
- this.TextChanged += (obj, e) =>
- {
- this.Text = e.TextField.Text;
- };
- }
- }
- }
-
/// <summary>
/// Get the InputMethodContext instance.
/// </summary>
}
}
+ TextChanged -= TextFieldTextChanged;
+
base.Dispose(type);
}
}
}
+ private void TextFieldTextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (!isSettingTextInCSharp)
+ {
+ EnforceNotifyBindedInstance(TextProperty);
+ }
+ }
+
internal new class Property
{
internal static readonly int TEXT = Interop.TextField.TextGet();
SetBinding(targetProperty, binding, false);
}
- private bool isCreateByXaml = false;
- /// Only used by the IL of xaml, will never changed to not hidden.
+ /// Internal used, will never changed to not hidden.
[EditorBrowsable(EditorBrowsableState.Never)]
- public virtual bool IsCreateByXaml
+ public bool IsCreateByXaml
{
- get
- {
- return isCreateByXaml;
- }
- set
+ get;
+ set;
+ }
+
+ /// This will be public opened in next ACR.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void EnforceNotifyBindedInstance(BindableProperty property)
+ {
+ if (null != property)
{
- isCreateByXaml = value;
+ BindablePropertyContext context = GetOrCreateContext(property);
+ BindingBase binding = context.Binding;
+
+ var currentlyApplying = applying;
+
+ if (binding != null && !currentlyApplying)
+ {
+ applying = true;
+ binding.Apply(true);
+ applying = false;
+ }
+
+ OnPropertyChanged(property.PropertyName);
+
+ PropertyToGroup.TryGetValue(property, out HashSet<BindableProperty> propertyGroup);
+
+ if (null != propertyGroup)
+ {
+ foreach (var relativeProperty in propertyGroup)
+ {
+ if (relativeProperty != property)
+ {
+ var relativeContext = GetOrCreateContext(relativeProperty);
+ var relativeBinding = relativeContext.Binding;
+
+ if (null != relativeBinding)
+ {
+ applying = true;
+ relativeBinding.Apply(true);
+ applying = false;
+ }
+
+ OnPropertyChanged(relativeProperty.PropertyName);
+ }
+ }
+ }
}
}
}
}
- internal void SetValueAndForceSendChangeSignal(BindableProperty property, object value)
- {
- if (property == null)
- throw new ArgumentNullException(nameof(property));
-
- if (true == IsBinded)
- {
- if (property.IsReadOnly)
- throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
-
- SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
- SetValuePrivateFlags.ManuallySet | SetValuePrivateFlags.CheckAccess, true);
- }
- else
- {
- property.PropertyChanged?.Invoke(this, null, value);
- }
- }
-
/// <summary>
/// Sets the value of the propertyKey.
/// </summary>
internal void SetValueCore(BindablePropertyKey propertyKey, object value, SetValueFlags attributes = SetValueFlags.None)
{
- SetValueCore(propertyKey.BindableProperty, value, attributes, SetValuePrivateFlags.None, false);
+ SetValueCore(propertyKey.BindableProperty, value, attributes, SetValuePrivateFlags.None);
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes = SetValueFlags.None)
{
- SetValueCore(property, value, attributes, SetValuePrivateFlags.Default, false);
+ SetValueCore(property, value, attributes, SetValuePrivateFlags.Default);
}
- internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, bool forceSendChangeSignal)
+ internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
{
bool checkAccess = (privateAttributes & SetValuePrivateFlags.CheckAccess) != 0;
bool manuallySet = (privateAttributes & SetValuePrivateFlags.ManuallySet) != 0;
else
{
context.Attributes |= BindableContextAttributes.IsBeingSet;
- SetValueActual(property, context, value, currentlyApplying, forceSendChangeSignal, attributes, silent);
+ SetValueActual(property, context, value, currentlyApplying, attributes, silent);
Queue<SetValueArgs> delayQueue = context.DelayedSetters;
if (delayQueue != null)
while (delayQueue.Count > 0)
{
SetValueArgs s = delayQueue.Dequeue();
- SetValueActual(s.Property, s.Context, s.Value, s.CurrentlyApplying, forceSendChangeSignal, s.Attributes);
+ SetValueActual(s.Property, s.Context, s.Value, s.CurrentlyApplying, s.Attributes);
}
context.DelayedSetters = null;
return;
SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
- (fromStyle ? SetValuePrivateFlags.FromStyle : SetValuePrivateFlags.ManuallySet) | (checkAccess ? SetValuePrivateFlags.CheckAccess : 0),
- false);
+ (fromStyle ? SetValuePrivateFlags.FromStyle : SetValuePrivateFlags.ManuallySet) | (checkAccess ? SetValuePrivateFlags.CheckAccess : 0));
}
- void SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, bool forceSendChangeSignal, SetValueFlags attributes, bool silent = false)
+ void SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent = false)
{
object original = context.Value;
bool raiseOnEqual = (attributes & SetValueFlags.RaiseOnEqual) != 0;
PropertyToGroup.TryGetValue(property, out HashSet<BindableProperty> propertyGroup);
- if (!silent)
+ if (!silent && (!same || raiseOnEqual))
{
- if ((!same || raiseOnEqual))
- {
- property.PropertyChanged?.Invoke(this, original, value);
-
- if (binding != null && !currentlyApplying)
- {
- applying = true;
- binding.Apply(true);
- applying = false;
- }
-
- OnPropertyChanged(property.PropertyName);
-
- if (null != propertyGroup)
- {
- foreach (var relativeProperty in propertyGroup)
- {
- if (relativeProperty != property)
- {
- var relativeContext = GetOrCreateContext(relativeProperty);
- var relativeBinding = relativeContext.Binding;
+ property.PropertyChanged?.Invoke(this, original, value);
- if (null != relativeBinding)
- {
- applying = true;
- relativeBinding.Apply(true);
- applying = false;
- }
-
- OnPropertyChanged(relativeProperty.PropertyName);
- }
- }
- }
- }
- else if (true == same && true == forceSendChangeSignal)
+ if (binding != null && !currentlyApplying)
{
- if (binding != null && !currentlyApplying)
- {
- applying = true;
- binding.Apply(true);
- applying = false;
- }
+ applying = true;
+ binding.Apply(true);
+ applying = false;
+ }
- OnPropertyChanged(property.PropertyName);
+ OnPropertyChanged(property.PropertyName);
- if (null != propertyGroup)
+ if (null != propertyGroup)
+ {
+ foreach (var relativeProperty in propertyGroup)
{
- foreach (var relativeProperty in propertyGroup)
+ if (relativeProperty != property)
{
- if (relativeProperty != property)
- {
- var relativeContext = GetOrCreateContext(relativeProperty);
- var relativeBinding = relativeContext.Binding;
-
- if (null != relativeBinding)
- {
- applying = true;
- relativeBinding.Apply(true);
- applying = false;
- }
+ var relativeContext = GetOrCreateContext(relativeProperty);
+ var relativeBinding = relativeContext.Binding;
- OnPropertyChanged(relativeProperty.PropertyName);
+ if (null != relativeBinding)
+ {
+ applying = true;
+ relativeBinding.Apply(true);
+ applying = false;
}
+
+ OnPropertyChanged(relativeProperty.PropertyName);
}
}
}