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

  • SEARCH
  • Home
  • 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 8886099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:28:32+00:00 2026-06-14T21:28:32+00:00

If TL;DR: see the last paragraph. Pure WPF suggests putting presentation (controls, text, icons)

  • 0

If TL;DR: see the last paragraph.

Pure WPF “suggests” putting presentation (controls, text, icons) into views and command logic (Execute, CanExecute methods) into code-behind. Besides putting logic both into views (CommandBindings) and code-behind being a frowned upon practice, it doesn’t help at all with XAML duplication: text, icons, large icons, hints, and numerous other properties have to be duplicated every time a command is used: for main menu, for context menu, for toolbar button, for ribbon button and other controls.

Looks like the first problem (truly separating views and logic) is solved by DelegateCommand, RelayCommand and approaches like that. Command logic is moved into ViewModels (or Controllers in case of MVVMC), code-behind is clean, no CommandBindings and other nonsense in views.

However, I can’t find a commonly accepted solution to the presentation duplication problem. I want to separate command presentation (text, icons) and command logic (Execute, CanExecute methods). All code I could find either puts presentation into code (by creating a RoutedCommand with additional properties like Label and Icon), or puts code into presentation (that is, handlers into views and code-behind). I don’t like either. I think presentation should be completely in XAML, and code should be completely in CS (either in ViewModel or Controller).

Question: how to separate views (XAML with controls which reference commands), presentation of commands (labels, icons etc. for every command) and logic of commands (C# code for Execute, CanExecute etc. in ViewModels or Controllers)?

  • 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-06-14T21:28:33+00:00Added an answer on June 14, 2026 at 9:28 pm

    There is no built-in solution to this problem, your’re going to have to roll-up your sleeves and create the required structure yourself.

    In a recent project I worked on, I did exactly this. I created a concept called an ‘action’ which supplements the WPF ICommand with other visual properties. It was something like this …

    interface IAction
    {
      ICommand Command { get; }
      string DisplayText { get; }
      string ToolTipText{ get; }
      URI Icon { get; }
    }
    

    The application contained a collection of Action instances. These could then be bound to menus, toolbars etc … allowing the same Action instance to be re-used with various different presentation styles. It is all fairly straightforward MVVM stuff!

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

Sidebar

Related Questions

I have spent the last hour trying to see what I'm doing wrong, or
I screwed up my last post. Lets see if I can get this one
I have installed last version 853.20120605-0921 of ExtLib... In designer I don't see under
After having my last question answered , I have never see the preventDefault(); function
Is there a an easy way to see(timestamp) when a database was last altered
This is solved at last with timeout attribute of jQuery AJAX (and JSONP). See
OK, I thought I would try one last update and see if it gets
I dont't see last button (bx), when first button array too big, for example
Let's say file.txt.gz has 2GB, and I want to see last 100 lines or
When I open terminal I see: Last login: Sun Aug 26 15:33:57 on ttys001

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.