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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:17:46+00:00 2026-06-04T06:17:46+00:00

Say I have a TabControl that is presenting a collection of Foo objects (each

  • 0

Say I have a TabControl that is presenting a collection of Foo objects (each through a FooViewModel). At the end of the list of tab items, I want a faux tab item that doesn’t model anything, but which creates a new model item and adds it to the collection when clicked.

If the concept isn’t clear, a real example is the tabs in Internet Explorer. It has n+1 tab items: n which have page content, and the last one which adds a new ‘real’ tab.

What’s the correct way (if any) to model this type of interaction in MVVM? The options I’ve thought of are:

  • Make it part of the view model. At the end of the IEnumerable<FooViewModel> Foos collection that the control is bound to, add a ‘new item’ sentinel and build the ‘am I a real foo or a new foo sentinel’ logic into the view model.

  • Make it wholly part of the view. Re-template (and/or subclass) TabControl to present all the real items and then also a button which invokes the command to create and insert a new item.

The first option feels wrong at first, like it’s leaking view details into the view model (it seems quite likely that ‘add a new Foo‘ is a general command, and some view may not want it invokable from the tab list at all). But it does make some amount of sense, because for the initialization process I’ll already need to model a ‘semi-constructed Foo‘, so a model of a ‘not-yet-existing Foo‘ doesn’t seem so far off.

The second part seems like a lot of work and also easy to screw up (assuming the desire is for it to look and feel like the other tabs).

But I’m new to MVVM; surely this comes up pretty often. Maybe I’m missing something entirely. What’s the traditional way to deal with it?

  • 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-04T06:17:47+00:00Added an answer on June 4, 2026 at 6:17 am

    A couple of the key tenants of the MVVM pattern are:

    • Testability – by making your view as simple as possible, by moving logic into your view-model, you increase the amount of logic you can test via unit testing.
    • Designer-Support – a mock view-model can be used to supply design-time data to your view.

    Which of your suggestions best fulfills the above? I would say option (1). You can write unit tests to ensure that the last item in the list is always a ‘sentinel’ item.

    In order to “build ‘am I a real foo or a new foo sentinel’ logic into the view model.”, you can simply use typed DataTemplates.

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

Sidebar

Related Questions

I have a TabControl where each tab contains a DataGrid . When the user
Say for instance I have a C# Winforms applciations that uses a tabcontrol with
Say i have a tab control that displays data of various types, eg EditorTabViewModel
Say I have a Textbox nested within a TabControl . When the form loads,
Say I have the following generic class: public class Foo<T extends Bar> { //
Say I have a method that returns this. Vector[ (PkgLine, Tree) ]() I want
Say I have some foo :: Maybe Int and I want to bind it
Say I have two types of objects, Apples and Chainsaws . A user is
Say I have a LINQ-to-XML query that generates an anonymous type like this: var
Say I have XAML like <TabControl Grid.Row=1 Grid.Column=2 ItemsSource={Binding Tabs} IsSynchronizedWithCurrentItem=True> <TabControl.ItemTemplate> <DataTemplate> <TextBlock

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.