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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:33:46+00:00 2026-05-23T19:33:46+00:00

I created a view and viewmodel that I would like to use twice (or

  • 0

I created a view and viewmodel that I would like to use twice (or more) in the same application. I would like however to have it bound to two different models.

<TabItem Background="Transparent">
            <TabItem.Header>
                <TextBlock Text="Items" Foreground="LightSeaGreen" FontSize="14"/>
            </TabItem.Header>
            <AdornerDecorator>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="250" />
                    </Grid.ColumnDefinitions>

                    <local:ItemsView Grid.Row="0" Grid.Column="0" Margin="5" Height="Auto"/>
                    //This is the reused control
                    <local:NutritionLabelView Grid.Row="0" Grid.Column="1" Margin="5,15,5,5" Height="Auto" VerticalAlignment="Top" ViewKey="Key_ItemsView" />

                </Grid>
            </AdornerDecorator>
        </TabItem>

        <TabItem Background="Transparent">
            <TabItem.Header>
                <TextBlock Text="Meals" Foreground="LightSeaGreen" FontSize="14"/>
            </TabItem.Header>
            <AdornerDecorator>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="250" />
                    </Grid.ColumnDefinitions>

                    <local:MealsView Grid.Column="0" Margin="5" Height="Auto"/>
                     //This is it again
                    <local:NutritionLabelView Grid.Column="1" Margin="5,15,5,5" Height="Auto" VerticalAlignment="Top" ViewKey="Key_MealsView" />

                </Grid>
            </AdornerDecorator>

        </TabItem>

The control that is reused is the <local:NutritionLabelView Grid.Column="1" Margin="5,15,5,5" Height="Auto" VerticalAlignment="Top" ViewKey="Key_MealsView" /> which I gave a ViewKey property to so I could tell which data this view should display. Can I use a multibinding for this?

  • 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-23T19:33:46+00:00Added an answer on May 23, 2026 at 7:33 pm

    I figured this out by binding each of the view’s controls to the same property in the viewmodel and made the property of type Object. Then based on the view key returned the correct type of object. Works for me.

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

Sidebar

Related Questions

I have an MVC3 application with Razor and I created a View that inside
I have a view model like so that is created from my validator. public
if i have created a view model and have a partial form that is
I have created a list view that displays the names and dates of items
I have created an alert view with two buttons using the following code: UIAlertView
I created a control which is hosting two content controls. I would like Caliburn
I have created View A and View B. My window has View A displayed
I have a primary link accommodation, then i have created a view , called
I've created a new View-based Application in XCode. In the ViewController, the only code
I would like to use autocompletebox with a list of values, but also add

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.