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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:23:29+00:00 2026-05-30T22:23:29+00:00

I use C#, MVVM, WPF and Resharper. When using the following code: public bool

  • 0

I use C#, MVVM, WPF and Resharper.

When using the following code:

    public bool CombiBanksSelected
    {
        get { return _selectedBanksType == ESelectedBanksType.CombiBanks; }
        set
        {

I get a warning of Resharper: Make set accessor private.

When making the set method private, I get an InvalidOperationException: A TwoWay or OneWayToSource binding cannot work on the read-only property ”CombiBanksSelected” of type ”PcgTools.ViewModels.PcgViewModel.’

Of course I can suppress it by adding:

    public bool CombiBanksSelected
    {
        get { return _selectedBanksType == ESelectedBanksType.CombiBanks; }
// ReSharper disable MemberCanBePrivate.Global
        set
// ReSharper restore MemberCanBePrivate.Global
        {

But this is not looking nice and not feeling good. Is there a better alternative or solution for this problem?

According to the answer I should change the XAML code. Mine is:

<UserControl x:Class="PcgTools.PcgWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ViewModels="clr-namespace:PcgTools.ViewModels" Height="Auto" Width="Auto" 
    Loaded="Window_Loaded">

<Grid>
  ...
    <RadioButton Content="_Programs" Height="16" HorizontalAlignment="Left" Margin="12,12,0,0" Name="radioButtonPrograms" VerticalAlignment="Top" 
                 IsChecked="{Binding Path=ProgramBanksSelected}" IsEnabled="{Binding Path=ProgramsEnabled}"/>
    <RadioButton Content="_Combis" Height="16" HorizontalAlignment="Left" Margin="85,12,0,0" Name="radioButtonCombis" VerticalAlignment="Top" 
                 IsChecked="{Binding Path=CombiBanksSelected}"  IsEnabled="{Binding Path=CombisEnabled}"/>

I have the Resharper problem for both (and more) properties binded to IsChecked (ProgramBanksSelected and CombiBanksSelected in the code above).

In the answer is shown that I should use a DataTemplate, but I still can’t figure out how exactly (with not using MVVM light’s Locator).

How should I use the data context/template?

  • 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-30T22:23:30+00:00Added an answer on May 30, 2026 at 10:23 pm

    In addition to Phil’s excellent suggestions, you can also use the UsedImplicitlyAttribute. You can use Nuget to do add the dll for you

    enter image description here

    And then R# will itself offer to decorate the setter with the attribute:

    public bool CombiBanksSelected
    {
        get { return _selectedBanksType == ESelectedBanksType.CombiBanks; }
        [UsedImplicitly] set
        {
    

    I find it less noisy than a comment, and well suited to a ViewModel where it’s understood that data bindings are typically unknown to R#. (sometimes I actually prefer a comment to remind me why I wanted R# to shut up, but not in this case).

    Cheers,
    Berryl

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

Sidebar

Related Questions

When writing a WPF application using MVVM, I want to use a WCF service,
I would like to use an MVVM in a WPF project I'm working on,
I am attempting to use an MVVM-ish approach to my WPF development. I have
How to use MVVM in WPF Browser Application? I want to know how to
I want use MVVM design pattern in WPF and Silverlight Application. Where can i
Im writing a wpf project and using the MVVM paradigm, what i was wondering
I have a wpf application using mvvm approach. The main window contains a tab
I am using the MVVM pattern for a WPF application. In several places I
We're using the WPF DataGrid from the WPF Toolkit and are employing MVVM. I'm
I'm creating a WPF application using the MVVM design pattern that consists of a

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.