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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:17:30+00:00 2026-05-14T14:17:30+00:00

This is probably mostly a question about how to use the VS 2010 IDE

  • 0

This is probably mostly a question about how to use the VS 2010 IDE tools in a way the Microsofties didn’t specifically intend. But since this is something I immediately tried without success.

I have defined a .NET 4.0 WPF Application project with a simple class that looks like this:

Public Class Class1
    Public Property One As String = "OneString"
    Public Property Two As String = "TwoString"
End Class

I then defined it as an "Object Data Source" in VS2010, using the IDE’s "Add New Data Source…" feature. This exposes the class members in a GUI element in the IDE as given in this image:
Image of Data Sources Tool
(source: finitesolutions.com)

Dragging "Class1" from that tool to the surface of "Window1.xaml" in a default "WPF Application" results in the design view looking like this:

Dragged from Data Sources Tool
(source: finitesolutions.com)

And generated XAML like this:

<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="133" Width="170" xmlns:my="clr-namespace:WpfApplication1" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
>
<Window.Resources>
    <CollectionViewSource x:Key="Class1ViewSource" d:DesignSource="{d:DesignInstance my:Class1, CreateList=True}" />
</Window.Resources>
<Grid DataContext="{StaticResource Class1ViewSource}" HorizontalAlignment="Left" Name="Grid1" VerticalAlignment="Top">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Label Content="One:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
    <TextBlock Grid.Column="1" Grid.Row="0" Height="23" HorizontalAlignment="Left" Margin="3" Name="OneTextBlock" Text="{Binding Path=One}" VerticalAlignment="Center" />
    <Label Content="Two:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
    <TextBlock Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="TwoTextBlock" Text="{Binding Path=Two}" VerticalAlignment="Center" />
</Grid>

Note the data bindings Text="{Binding Path=One}" and Text="{Binding Path=Two}" in the TextBlock elements.

Code-behind for Window1.xaml has this in Window_Loaded:

   Class Window1
        Private m_c1 As New Class1
        Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
            Dim Class1ViewSource As System.Windows.Data.CollectionViewSource = CType(Me.FindResource("Class1ViewSource"), System.Windows.Data.CollectionViewSource)
            'Load data by setting the CollectionViewSource.Source property:
            'Class1ViewSource.Source = [generic data source]
            Me.DataContext = m_c1
        End Sub
    End Class

Running the application produces this output:

Running Application
(source: finitesolutions.com)

The expected result was that "OneString" would appear next to "One" and "TwoString" next to "Two" in the running window.

The question is: Why didn’t this work? What will work instead? If I put bindings in a DataTemplate, it works. Blend, with its sample data stuff, implied that this should work, but it doesn’t. I know I’m missing something pretty fundamental here; what is 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-05-14T14:17:30+00:00Added an answer on May 14, 2026 at 2:17 pm

    I found this answer relatively quickly, so I’ll answer my own question.

    The generated XAML code contains this:

    <Grid DataContext="{StaticResource Class1ViewSource}"

    Removing the DataContext="{StaticResource Class1ViewSource}" removed something that had masked the Window.DataContext, and the binding worked.

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

Sidebar

Related Questions

This probably is a dummy question but I cannot find a clear indication. I
Im sorry for this probably dumm question, but I want to simply open modals
i have a quite weird question which probably has no practical use but the
This is probably a naive question here but I'll ask it anyway. I'm working
This is probably a very generic question but I will shoot anyway since I
Probably a simple question, but: My app starts (and is mostly) in portrait mode,
So I'm sure this is probably at least mostly insane, but I was just
This probably sounds like a terrible idea at first glance, but here is my
I know this probably really simple but Im not sure what im doing wrong...
I know this probably has been asked before but I am having issues with

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.