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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:24:55+00:00 2026-06-14T23:24:55+00:00

Using the following sample R# (resharper) is not able to find the datacontext of

  • 0

Using the following sample R# (resharper) is not able to find the datacontext of the Row style and warns about a wrong binding (at runtime works fine). Seems like the Style is not getting the DataContext of the ItemsSource:

enter image description here

MainWindow.xaml:

<Window x:Class="TestDatacontext.MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:testDatacontext="clr-namespace:TestDatacontext"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DataContext="{d:DesignInstance testDatacontext:MainWindowVM}"  >

<DataGrid ItemsSource="{Binding Items}" >
    <DataGrid.RowStyle>
        <Style TargetType="DataGridRow" >
            <Setter Property="Header" Value="{Binding Name}" />
        </Style>
    </DataGrid.RowStyle>
</DataGrid>
</Window>

MainWindowVM:

using System.Collections.ObjectModel;

namespace TestDatacontext
{
    class MainWindowVM
    {
        public ObservableCollection<ItemVM> Items { get; private set; }
    }
}

ItemVM:

namespace TestDatacontext
{
    class ItemVM
    {
        public string Name { get; set; }
    }
}
  • 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-14T23:24:56+00:00Added an answer on June 14, 2026 at 11:24 pm

    You are correct, ReSharper has no knowledge about how RowStyle will be used in this particular control (is it style per every item of ItemsSource? or some kind of header style and bindings will have access to ItemsSource object itself?), so it stops traversing tree looking for DataContext type on Style declaration.

    This issue can be solved with additional annotation on Style declaration:

    <Style TargetType="DataGridRow" d:DataContext="{d:DesignInstance vms:ItemVM}">
      <Setter Property="Header" Value="{Binding Name}" />
    </Style>
    

    Project will compile fine, VS designer and R# will work, but VS xaml support will produce 1 error in errors window – “Property ‘DataContext’ is not attachable to elements of type ‘Style'”. That’s a bit annoying, but works. Other way is to quilify property type like this:

    <Style TargetType="DataGridRow">
      <Setter Property="Header" Value="{Binding (vms:ItemVM.Name)}" />
    </Style>
    

    But it produces VS xaml support error too 🙂 and have slightly different behavior in runtime – this binding will work only with Name property of ItemVM type and will not work if somehow VM object will be replaced with some other object of different type with Name property at runtime (so binding became “strongly-typed”).

    We are still looking for a better way to solve this kind of problems in ReSharper 8.0 and make VS designer happy, sorry for confusing!

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

Sidebar

Related Questions

I'm using XOM with the following sample data: Element root = cleanDoc.getRootElement(); //find all
I'm not able to debug my tests using Resharper-Debug option in my project. I
I have a Dictionary bound to DataGridView by using following sample code. DataGridView bound
I'm using Hibernate 3.3.1 and am following along in modelling this sample table structure
I am using the following sample at http://blogs.msdn.com/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx within VB.NET. The code is shown
I am using the following sample to display text in the background of the
Using the TinyCarousel program I created the following sample page. http://www.dealred.com/wa/jqimage.htm The carousel is
Consider the following sample code: #include <iostream> using namespace std; class base { public:
I'm using the following sample code from the DotnetOpenAuth Samples (OpenId Controller in OpenIdProviderMvc)
I'm using following code to display an image with CodeIgniter framework. <?php echo img('sample/logo.png');

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.