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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:29:33+00:00 2026-05-22T20:29:33+00:00

Hi I am trying to understand the best practise to use nested views. I

  • 0

Hi I am trying to understand the best practise to use nested views.

I have an ‘Attribute’ View which is bound to collection of name value pairs in the view model. I need to reuse this at various places in my UI.

I have another ‘Condition View’ which has a string property and Dictionary(string,string) collection. I tried to create a text box and add the Attribute View control in the XAML

    <StackPanel>
        <StackPanel Orientation="Horizontal">
            <Label Content="{x:Static l:StringResources.ConditionViewLabelText}" />
            <TextBox Text="{Binding Type,Mode=TwoWay}" Width="100" />
        </StackPanel>
        <vw:AttributeView />
    </StackPanel>

I want to bind the AttributeView’s bound property to the Dictionary(string,string)’s collection property of the parent view model. Whats the best way to do it. I am not able to bind the vw:AttributeView to a ConditionViewModels ?

Can you please let me know the best practise to do this?

— EDIT Please find my AttributeView (This is the child view’s xaml code). The data template is bound to an observable collection on the AttributeViewModel

 <StackPanel>
        <ItemsControl ItemsSource="{Binding AllAttributes}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBox Width="100" Text="{Binding Name, Mode=TwoWay}" Margin="5,0,5,0" />
                        <TextBox Width="100" Text="{Binding Value, Mode=TwoWay}" Margin="5,0,5,0" />
                        <TextBlock Width="100" Text="{Binding KeyValue, Mode=OneWay}" />
                        <Button Width="50" Content="{x:Static l:StringResources.AttributeViewButtonDeleteText}" Command="{Binding Path=DataContext.DeleteAttribute, ElementName=AttributeControl}" CommandParameter="{Binding Name}"></Button>
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <Button Name="btnSomething" Content="{x:Static l:StringResources.AttributeViewButtonAddText}" Command="{Binding AddNewAttribute}" />
    </StackPanel>
</Grid>
  • 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-22T20:29:34+00:00Added an answer on May 22, 2026 at 8:29 pm

    Based on your comments that your parent / child relationship is not reflected in your view model, you have two options:

    1. Create the relationship in your view model to reflect the relationship in your view, allowing you to navigate from the parent to the child and vice-versa should you need this.
    2. Use a RelativeSource FindAncestor binding to navigate up the visual tree and locate a control bound to the parent view model, biding to this controls DataContext.

    Option (2) will make you look clever, but option (1) is much simpler!

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

Sidebar

Related Questions

I'm trying to understand the best way to use Spring (for dependency injection) with
I'm trying to understand what's the best Cache-Control value to be set for static
I'm trying to understand the best options for pulling off a wizard form in
Been trying my best to understand this correctly. What is the difference between an
I'm fairly new to C programming but trying my best to understand it. I
I'm trying to decide on the best strategy for accessing the database. I understand
Trying to understand the math of this code snippet. A token is provided which
I am trying to define which agile practices we are going to use, and
I understand it is best practise to call Dispose() on instances of Pen and
I'm trying to understand what const_iterator means. I have the following example code: void

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.