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 6371751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:07:33+00:00 2026-05-25T01:07:33+00:00

I know binding a view model to a view is ok, view models containing

  • 0

I know binding a view model to a view is ok, view models containing view models is ok, and views containing views is ok. I have a situation where it seems a sub-view needs to be bound to a view.

In particular, I have a case where a particular command’s implementation does not need to be in nor manipulate a view model in any way (and doesn’t affect the underlying model-model either). I could put the command in a view model, bind it, and execute it, but that’s a definite code smell preventing clean separation of the view model layer from the view layer.

The command is initiated from a parent view, but affects a child view. I can think of several ways to handle this.

  • Add an event handler in the parent, somehow find the right child (not sure how to do that in Silverlight), and then do all the logic I need.
  • Handle the event in the parent, but re-raise a different event (double dispatch). In the child, handle the second event, and do the logic.
  • Bind the command to the parent and handle the logic in the command itself (or in the parent view’s supplied delegate).
  • Bind the command to the child view directly. In this case how would I specify the binding in the parent view’s xaml to the right child view/control?
  • Bind the command to the child view’s view model as defined above.

What should I do?

  • 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-25T01:07:34+00:00Added an answer on May 25, 2026 at 1:07 am

    The “No-Code-Behind” rule for MVVM is not meant to apply to code that is only related to the UI, such as setting focus, running animations, adjusting sizes, etc. So in your case, I’d put the code behind your Views, and just have one View reference the other.

    Providing your Business Logic code stays in your ViewModels, and your Presentation/UI code stays behind your Views, you’re good.

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

Sidebar

Related Questions

If I have some (non-volatile) data bound to the UI via a view model,
Question: How do send data to a view model when using command binding? So
I want to have a command from my view model associated with F8, and
I know it could be bad to use domain models as view models. If
I have created a View Model in Silverlight. This View Model has an event
I would like to know how exactly model binding works in ASP.NET MVC3. Since
I have a view (MainPage.xaml) which is bound to a ViewModel. In the ViewModel
I have a grid view which I am binding with data table. My problem
I know that WPF 3.5 SP1 supports a StringFormat in a binding, but can
I know, I would have thought the answer was obviously no as well, but

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.