'Custom Control Entry not getting set the Place Holder Color Bindable Property
I have a custom control its a date picker but the PlaceHolderColor is not being set and not having affect.
public Color PlaceHolderColorText
{
get =>
(Color)GetValue(PlaceHolderColorProperty);
set => SetValue(PlaceHolderColorProperty,
value);
}
public static readonly BindableProperty
PlaceHolderColorProperty =
BindableProperty.Create(nameof(PlaceHolderColor),
typeof(Color),
typeof(DateTimePicker2),Color.Black , BindingMode.TwoWay,
propertyChanged: OnPlaceHodlerColorChanged);
I am creating dynamic entrys as such
public Entry _dayEntry { get; private set; } = new Entry() {
TabIndex = 0, Placeholder = "dd", Keyboard = Keyboard.Numeric,
WidthRequest = 60, HorizontalOptions = LayoutOptions.Start };
public Entry _monthEntry { get; private set; } = new Entry() {
TabIndex = 1, Placeholder = "MM", Keyboard = Keyboard.Numeric,
WidthRequest = 60, HorizontalOptions = LayoutOptions.Start };
But I am unsure as to what I need here to get the value to apply to the entry properly
public static void OnPlaceHodlerColorChanged(BindableObject
bindable, object oldValue, object newValue)
{
var test = newValue;
///do something with new but dont no what.
}
I am adding my entrys like this to the children of the stack
public DateTimePicker2()
{
BindingContext = this;
_dayEntry.TextChanged += _dayEntry_TextChanged;
_monthEntry.TextChanged += _monthEntry_TextChanged;
_yearEntry.TextChanged += _yearEntry_TextChanged;
_dayEntry.TextColor= TextColor;
_monthEntry.TextColor= TextColor;
_yearEntry.TextColor= TextColor;
_dayEntry.PlaceholderColor = PlaceHolderColor;
_monthEntry.PlaceholderColor = PlaceHolderColor;
_yearEntry.PlaceholderColor = PlaceHolderColor;
_hourEntry.TextColor= TextColor;
_minsEntry.TextColor= TextColor;
SelectedDateChanged +=DateTimePicker2_SelectedDateChanged;
Content = new StackLayout()
{
Orientation = StackOrientation.Horizontal,
Children =
{ _datePicker,
_timePicker,
_monthEntry,
_dayEntry,
_yearEntry,
_hourEntry,
_minsEntry,
_ampmPicker,
iconButton
}
};
I am a bit perplexed as to what to do to get the event to register the place holder color to correct entry you will see am doing here.
_dayEntry.PlaceholderColor = PlaceHolderColor;
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
