none
Binding error for UserControl "The member Resources is not recognized or is not accessible". RRS feed

  • Question

  • Hello,

    I have a weird issue in my code that I want to share with you and it is related to the binding in the view.I want to set the datacontext for the view,but when I write <UserControl.Resources> I get the error in the title("The member Resources is not recognized or is not accessible").This is how I set the datacontext for the usercontrol:

    View.xaml.cs:

      RegisterStudentViewModel vm;
            public RegisterStudent()
            {
                InitializeComponent();
                vm = new RegisterStudentViewModel();
                this.DataContext = vm;
            }

    View.xaml:

    <UserControl x:Class="WPFAttendanceApp.View.RegisterStudent"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 xmlns:local="clr-namespace:WPFAttendanceApp.ViewModel"
                 mc:Ignorable="d" 
                 d:DesignHeight="450" d:DesignWidth="800">
        <Border Background="#2e3137" CornerRadius="20" Margin="20">
            <UserControl.Resources>
                <local:RegisterStudentViewModel/>
            </UserControl.Resources>

    What am I doing wrong and how should I establish the binding in the view?

    Tuesday, May 1, 2018 9:33 AM

All replies

  • Please try to change platform from AnyPC to x86 or x64 and see.

     

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, May 3, 2018 3:21 AM
  • Have you tried to place <UserControl.Resources> outside the <Border>?
    Thursday, May 3, 2018 4:38 AM
  • Yes and sorry for the late response.I have tried as you said but it didn't work.For now I'm gonna keep it as a window and later on I'll try to find out the problem if it will be necessary to change.Thank you for your help.

    Best regards,

    Maria

    Monday, May 7, 2018 9:21 AM