Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6188721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:17:07+00:00 2026-05-24T02:17:07+00:00

Folks I am working in UI design in a project where our team chose

  • 0

Folks

I am working in UI design in a project where our team chose to decouple C# and XAML as much as possible.

I’ve been having trouble to create Styles for many common widgets (buttons, etc.) and some UserControls, specially because I don’t-want/don’t-know-how/am-not-supposed to use code-behind.

What I want to do is to be able to change properties of elements that are “deep within” the layout tree of my UserControls.

For example, suppose I have an UserControl that is a Border, which contains a StackPanel, which contains a colorful Ellipse and other things.

I want to be able to instantiate this user control and change only the color of the ellipse, like this:

<MyUserControl Background="Gray" EllipseColor="LightGreen" />

where “EllipseColor” would be some “custom” property defined in the UserControl.

I tried DependencyProperty within styles, but got no success, although I “feel” there must be a simple way to do this.

Any help (links, code snippets) would be much welcome.

Thanks for reading.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:17:08+00:00Added an answer on May 24, 2026 at 2:17 am

    The “No Code Behind” rule in MVVM is for keeping the View and the ViewModel completely separate, and should not be used for view-specific code such as DependencyProperties. Its like saying “Build a house out of these square blocks, but I want a rounded roof and you can’t create your own building blocks”. The whole point of DependencyProperties is to create additional Properties for your Views that don’t already exist.

    The important bit is that the View doesn’t directly reference the ViewModel, and vise versa.

    In your case, I would either create a DependencyProperty in the Code Behind for your UserControl for EllipseColor, or use something like the Background property of the UserControl and bind my Ellipse fill color to that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Folks, I've been having some trouble with a WF4 problem. I'm modeling a batch
Folks, I am having some trouble working with the After hook. I have organized
Greetings folks. I have this weird problem. In the project I'm working on now,
Folks, The project that I am working on requires that a certain video can
Hey folks, I have to apologize for my inexperience here, I've been working on
I'm working on a project with some folks who want to use TTNavigator rather
Folks I am surprised to see my code working, that I dont have any
folks! I have project in cc.net and this project nay start by 3 ways
Folks, We have been using OpenXml APIs found in System.IO.Packaging for creating a package
Folks, I really like the -Wshadow option since it helps to spot some possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.