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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:27:22+00:00 2026-05-11T14:27:22+00:00

I’m rebuilding Josh Smith’s WPF CommandSink example and there are a few things that

  • 0

I’m rebuilding Josh Smith’s WPF CommandSink example and there are a few things that I don’t understand about his databinding, especially about how datacontext is inherited when a view is contained in another view which is contained in a window which has a datacontext.

  • all databinding is declared in the XAML files, there is absolutely no code behind the Window or either of the Views (nice)
  • the top Window defines its DataContext as CommunityViewModel and simply displays the CommunityView
  • Question: so now in the CommunityViewModel, what does the jas:CommandSinkBinding.CommandSink='{Binding}' do actually? ‘CommandSink’ is an attached property so is this ‘attaching’ the inherited Binding that comes from DemoWindow as the value of the attached property called ‘CommandSink’ on the CommandSinkBinding object?

  • Question: also, PersonView doesn’t seem to have a DataContext yet it has lines such as <TextBlock Text='{Binding Name}' Width='60' /> which assume that a binding is set. So does PersonView automatically get its binding from the line in CommunityView ItemsSource='{Binding People}'?

Thanks for any clarification here.

DemoWindow.xaml:

<Window    x:Class='VMCommanding.DemoWindow'   xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'   xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'   xmlns:view='clr-namespace:VMCommanding.View'   xmlns:vm='clr-namespace:VMCommanding.ViewModel'   FontSize='13'   ResizeMode='NoResize'   SizeToContent='WidthAndHeight'    Title='ViewModel Commanding Demo'      WindowStartupLocation='CenterScreen'   >   <Window.DataContext>     <vm:CommunityViewModel />   </Window.DataContext>    <Window.Content>     <view:CommunityView />   </Window.Content> </Window> 

CommunityView.xaml:

<UserControl    x:Class='VMCommanding.View.CommunityView'   xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'   xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'   xmlns:jas='clr-namespace:VMCommanding'   xmlns:view='clr-namespace:VMCommanding.View'   xmlns:vm='clr-namespace:VMCommanding.ViewModel'     jas:CommandSinkBinding.CommandSink='{Binding}'   >     <UserControl.CommandBindings>         <jas:CommandSinkBinding Command='vm:CommunityViewModel.KillAllMembersCommand' />     </UserControl.CommandBindings>      <DockPanel Margin='4'>         <ItemsControl       DockPanel.Dock='Bottom' ItemsSource='{Binding People}'>             <ItemsControl.ItemTemplate>                 <DataTemplate>                     <view:PersonView />                 </DataTemplate>             </ItemsControl.ItemTemplate>         </ItemsControl>         <Button        Command='vm:CommunityViewModel.KillAllMembersCommand'       Content='Kill All'       Margin='0,0,0,8'       />     </DockPanel> </UserControl> 

PersonView.xml:

<UserControl    x:Class='VMCommanding.View.PersonView'   xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'   xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'   xmlns:jas='clr-namespace:VMCommanding'   xmlns:vm='clr-namespace:VMCommanding.ViewModel'   jas:CommandSinkBinding.CommandSink='{Binding}'   >     <UserControl.CommandBindings>     <jas:CommandSinkBinding Command='vm:PersonViewModel.DieCommand' />     <jas:CommandSinkBinding Command='vm:PersonViewModel.SpeakCommand' />   </UserControl.CommandBindings>    <UserControl.Resources>     <Style TargetType='{x:Type TextBlock}'>       <Setter Property='Margin' Value='0,0,6,0' />       <Style.Triggers>         <DataTrigger Binding='{Binding CanDie}' Value='False'>           <Setter Property='Foreground' Value='#88000000' />         </DataTrigger>       </Style.Triggers>     </Style>   </UserControl.Resources>    <StackPanel Margin='2' Orientation='Horizontal'>     <TextBlock Text='Name:' FontWeight='Bold' />     <TextBlock Text='{Binding Name}' Width='60' />     <TextBlock Text='Age:' FontWeight='Bold' />     <TextBlock Text='{Binding Age}' Width='40' />     <Button        Command='vm:PersonViewModel.SpeakCommand'       CommandParameter='Howdy partner!'       Content='Speak'       Margin='0,0,6,0'       Width='60'       />     <Button       Command='vm:PersonViewModel.DieCommand'       Content='Die'       Width='60'       />   </StackPanel> </UserControl> 
  • 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. 2026-05-11T14:27:23+00:00Added an answer on May 11, 2026 at 2:27 pm

    If you set the ItemsSource of an ItemsControl, the DataContexts of the items in that control are directly mapped to the items of the ItemsSource.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.