Skip to content

Using RuntimePlatform with Styles #207

Closed Answered by mrlacey
HobDev asked this question in Q&A
Discussion options

You must be logged in to vote

<OpinionThatIWouldLikeFeedbackOn>
Styles are a XAML thing. Mixing them and C# Markup has the potential to give you a codebase that is still a mix of the two.

Declarative (XAML) and procedural languages (C#) have very fundamental differences and if you try and directly port one to the other you'll get bad code.

Don't try and write the direct C# equivalent of XAML.
Instead, ask yourself "How (in C#) would I create multiple types which have the same encapsulated logic?"

In doing that you might come up with the idea to use a factory method, or something similar.
So, you might have something like:

private Button CreateButton(string text)
{
    var btn = new Button().Text(text);
    // ... Add …

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@brminnick
Comment options

@mrlacey
Comment options

Answer selected by HobDev
Comment options

You must be logged in to vote
1 reply
@brminnick
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants