When I create a new Window, using the Add Item... dialogue, the Window I create, e.g. NewWindow
, does not inherit from Window. It only has the same interface as type Object
. An example:
I have the popup window code below. The code only sees the IHavePassword
members, and not the rest of the members of `LoginPopup', like its controls.
Public Class LoginPopup
Implements IHavePassword
Public ReadOnly Property Password As SecureString Implements IHavePassword.Password
Get
'Return Me.PasswordBox.????
End Get
End Property
Public Event PasswordChanged As RoutedEventHandler Implements IHavePassword.PasswordChanged
Public Sub PassWordChangedHandler(sender As Object, e As EventArgs)
PasswordChangedEvent(sender, e)
End Sub
Public Sub Close() Implements IHavePassword.Close
Throw New NotImplementedException
End Sub
End Class
OH, here is the necessary XAML as well:
<Window x:Class="ApptEase.Client.Prism.Views.LoginPopup"
....
<StackPanel Orientation="Vertical" Margin="0">
<DockPanel LastChildFill="True">
<TextBlock Text="{Binding Path=UsernameLabel}" DockPanel.Dock="Left" TextAlignment="Right" Margin="5,9,5,5" MinWidth="70" />
<TextBox Text="{Binding Path=Username, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" Width="Auto" Margin="5" />
</DockPanel>
<DockPanel LastChildFill="True">
<TextBlock Text="{Binding Path=PasswordLabel}" DockPanel.Dock="Left" TextAlignment="Right" Margin="5" MinWidth="70" />
<PasswordBox x:Name="PasswordBox" PasswordChanged="PassWordChangedHandler" Width="Auto" Margin="5" />
</DockPanel>
<DockPanel LastChildFill="True" Height="59">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Log in" Command="{Binding Path=LoginCommand}" CommandParameter="{Binding ElementName=This}" Margin="5" Padding="15,10,15,10" />
<Button Content="Cancel" Command="{Binding Path=CancelCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Margin="5" Padding="15,10,15,10"/>
</StackPanel>
</DockPanel>
</StackPanel>
The IntelliSense on the property Me
lists the members of IHavePassword
, e.g:
I would expect to see the controls and base Window
members here, not those of the interface. How do I go about fixing this?
NavigationService is for browser navigation within WPF. What you are trying to do is change to a different window TrainingFrm . To go to a different window, you should do this: private void conditioningBtn_Click(object sender, RoutedEventArgs e) { var newForm = new TrainingFrm(); //create your new form.
Window is the root control that must be used to hold/host other controls (e.g. Button) as container. Page is a control which can be hosted in other container controls like NavigationWindow or Frame. Page control has its own goal to serve like other controls (e.g. Button). Page is to create browser like applications.
Step 1: Create an empty WPF using Visual Studio, enter the name for the application and click on OK. Step 2: Create a button using the following code or drag and drop a button from the ToolBox of Visual Studio 2013.
I think you just forgot to surround the class with your namespace:
Namespace ApptEase.Client.Prism.Views
Public Class LoginPopup
Implements IHavePassword
'...
End Class
End Namespace
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With