My WPF application in C# makes use of the MVVM pattern. There are two user controls I have defined:
- LoginView
- ProjectsView
Both user controls are added to a main window and make use of the same view model. The LoginView
contains a PasswordBox
defined as follows:
<PasswordBox Name="passwordBox" IsEnabled={Binding PasswordEnabled} />
The ProjectsView
contains a button defined as follows:
<Button Content="Login" Command="{Binding ProjectLoginCommand}" IsEnabled={Binding ProjectLoginEnabled}" CommandParameter="{Binding ElementName=passwordBox}" />
When starting the application it seems as if the element name passwordBox
cannot be bound. The error message is:
Cannot find source for binding with reference 'ElementName=passwordBox' [...]
How can I fix this?