Here is the code that I currently have:
var FR2 = new Frame()
{
Content = CE,
CornerRadius = 5,
HasShadow = false,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Padding = new Thickness(10, 0),
Margin = new Thickness(0, 8),
};
FR2.SetDynamicResource(Frame.BackgroundColorProperty, "EntryBackgroundColor");
FR2.SetDynamicResource(Frame.BackgroundColorProperty, "EntryBorderColor");
Is there a way I can set these dynamic resources
BackgroundColor
BorderColor
inside of the { } part of the constructor for FR2 instead of adding them after?
Unfortunately, no. You cannot set the dynamic resources inside your initialiser. You have to set them afterwards with the SetDynamicResource
method.
As you can see, SetDynamicResource expects to be used with Element.SetDynamicResource()
. So, at least for now, this is not possible.
Taking into consideration that for the upcoming MAUI , the guys from Microsoft are spending more time into markup extensions for the code-behind, I won't be surprised if it comes in the near future.
Btw, you have a copy-paste mistake in the last row - you are binding the EntryBorderColor
to the BackgroundColorProperty
again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.