Click here to Skip to main content
15,886,629 members
Home / Discussions / WPF
   

WPF

 
QuestionResources not showing up in WPF control put in Winform Pin
pgmr_648044-Jun-16 5:36
pgmr_648044-Jun-16 5:36 
AnswerRe: Resources not showing up in WPF control put in Winform Pin
Gerry Schmitz5-Jun-16 8:09
mveGerry Schmitz5-Jun-16 8:09 
GeneralRe: Resources not showing up in WPF control put in Winform Pin
pgmr_648045-Jun-16 9:15
pgmr_648045-Jun-16 9:15 
QuestionTwo-Dimensional Datagrid Help Pin
madusanka8931-May-16 3:13
madusanka8931-May-16 3:13 
AnswerRe: Two-Dimensional Datagrid Help Pin
CHill6031-May-16 5:11
mveCHill6031-May-16 5:11 
GeneralRe: Two-Dimensional Datagrid Help Pin
Gerry Schmitz31-May-16 5:37
mveGerry Schmitz31-May-16 5:37 
GeneralRe: Two-Dimensional Datagrid Help Pin
CHill6031-May-16 5:42
mveCHill6031-May-16 5:42 
QuestionThe name "employeeviewmodel" does not exist in the namespace "clr-namespace:testwpfvbapplication.viewmodel". Pin
indian14326-May-16 10:24
indian14326-May-16 10:24 
Hi All,

I am using the following View and View Model in VB.Net, when I am trying to reference the View Model as DataContext
View is like this below
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
    xmlns:empns="clr-namespace:TestWPFVBApplication.ViewModel"
    Title="MainWindow" Height="350" Width="525">
    <Window.DataContext>
        <empns:EmployeeViewModel x:Name="_employeeViewModel" EmpId="1" EmpName="Abdul" EmpSalary="10000.00"
                DeptId="1">
            </empns:EmployeeViewModel>
    </Window.DataContext>
    <Grid>

    </Grid>
</Window>

And my View Model is as below
Namespace TestWPFVBApplication.ViewModel
    Public Class EmployeeViewModel
        Implements INotifyPropertyChanged, IDataErrorInfo

        Private _empId As Integer
        Public Property EmpId() As Integer
            Get
                Return _empId
            End Get
            Set(ByVal value As Integer)
                _empId = value
                NotifyPropertyChanged("EmpId")
            End Set
        End Property

        Private _empName As String
        Public Property EmpName() As String
            Get
                Return _empName
            End Get
            Set(ByVal value As String)
                _empName = value
                NotifyPropertyChanged("EmpName")
            End Set
        End Property

        Private _empSalary As Decimal
        Public Property EmpSalary() As Decimal
            Get
                Return _empSalary
            End Get
            Set(ByVal value As Decimal)
                _empSalary = value
                NotifyPropertyChanged("EmpSalary")
            End Set
        End Property

        Private _deptId As Integer
        Public Property DeptId() As Integer
            Get
                Return _deptId
            End Get
            Set(ByVal value As Integer)
                _deptId = value
                NotifyPropertyChanged("DeptId")
            End Set
        End Property

        Private _employees As ObservableCollection(Of Employee)
        Public Property Employees() As ObservableCollection(Of Employee)
            Get
                Return _employees
            End Get
            Set(ByVal value As ObservableCollection(Of Employee))
                _employees = value
                NotifyPropertyChanged("Employees")
            End Set
        End Property

        Private _error As String
        Public ReadOnly Property [Error] As String Implements IDataErrorInfo.Error
            Get
                Return _error
            End Get
        End Property

        Default Public ReadOnly Property Item(columnName As String) As String Implements IDataErrorInfo.Item
            Get
                If (columnName = "") Then
                    Return _error
                End If
                Return String.Empty
            End Get
        End Property

        Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged

        Private Property CanExecute As Boolean

        Private Sub NotifyPropertyChanged(propertyName As String)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
        End Sub

        Private _clickSaveCommand As ICommand
        Public ReadOnly Property ClickSaveCommand() As ICommand
            Get
                Return If(_clickSaveCommand, (InlineAssignHelper(_clickSaveCommand, New SaveEmployeeCommand(Sub() AddAnItem(), CanExecute))))
            End Get
        End Property

        Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
            target = value
            Return value
        End Function

        Private Sub AddAnItem()
            _employees.Add(New Employee(_empId, _empName, _empSalary, _deptId))
        End Sub

    End Class
End Namespace

And I am trying to reference the View Model as below
xmlns:empns="clr-namespace: TestWPFVBApplication.ViewModel.EmployeeViewModel"

And DataContext as below
<Window.DataContext>
    <empns:EmployeeViewModel x:Name="_employeeViewModel" EmpId="1" EmpName="Abdul" EmpSalary="10000.00"
            DeptId="1">
        </empns:EmployeeViewModel>
</Window.DataContext>

Then its giving me error, please help me any ideas or links or even suggestions would help me greatly.

Thanks in advance.
Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."


modified 26-May-16 19:08pm.

AnswerRe: The name "employeeviewmodel" does not exist in the namespace "clr-namespace:testwpfvbapplication.viewmodel". C:\users\abdul.aleem\desktop\testwpfapplication\testwpfvbapplication\view\mainwindow.xaml Pin
Richard Deeming26-May-16 10:55
mveRichard Deeming26-May-16 10:55 
GeneralRe: The name "employeeviewmodel" does not exist in the namespace "clr-namespace:testwpfvbapplication.viewmodel". Pin
indian14326-May-16 12:17
indian14326-May-16 12:17 
QuestionRequest Entity Too Large Pin
Mycroft Holmes25-May-16 21:57
professionalMycroft Holmes25-May-16 21:57 
AnswerRe: Request Entity Too Large Pin
Gerry Schmitz26-May-16 7:45
mveGerry Schmitz26-May-16 7:45 
GeneralRe: Request Entity Too Large Pin
Mycroft Holmes26-May-16 14:28
professionalMycroft Holmes26-May-16 14:28 
GeneralRe: Request Entity Too Large Pin
Mycroft Holmes26-May-16 17:58
professionalMycroft Holmes26-May-16 17:58 
QuestionHow to bind a nested Property of an attached Property Pin
Member 808505724-May-16 4:47
Member 808505724-May-16 4:47 
QuestionWPF Binding Question Pin
#realJSOP24-May-16 4:12
mve#realJSOP24-May-16 4:12 
AnswerRe: WPF Binding Question Pin
#realJSOP24-May-16 5:02
mve#realJSOP24-May-16 5:02 
QuestionBinding the x,y location on a Canvas with a ItemsControl Pin
Kenneth Haugland19-May-16 17:38
mvaKenneth Haugland19-May-16 17:38 
AnswerRe: Binding the x,y location on a Canvas with a ItemsControl Pin
Kenneth Haugland19-May-16 19:28
mvaKenneth Haugland19-May-16 19:28 
GeneralRe: Binding the x,y location on a Canvas with a ItemsControl Pin
Meshack Musundi23-May-16 2:54
professionalMeshack Musundi23-May-16 2:54 
GeneralRe: Binding the x,y location on a Canvas with a ItemsControl Pin
Kenneth Haugland23-May-16 11:26
mvaKenneth Haugland23-May-16 11:26 
GeneralRe: Binding the x,y location on a Canvas with a ItemsControl Pin
Pete O'Hanlon25-May-16 0:56
mvePete O'Hanlon25-May-16 0:56 
GeneralRe: Binding the x,y location on a Canvas with a ItemsControl Pin
Meshack Musundi25-May-16 1:27
professionalMeshack Musundi25-May-16 1:27 
QuestionRe: Binding the x,y location on a Canvas with a ItemsControl Pin
Kenneth Haugland7-Jun-16 20:22
mvaKenneth Haugland7-Jun-16 20:22 
GeneralRe: Binding the x,y location on a Canvas with a ItemsControl Pin
Meshack Musundi8-Jun-16 10:27
professionalMeshack Musundi8-Jun-16 10:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.