gpt4 book ai didi

.net - 为什么我创建的新 WPF Windows 不是从 Window 继承的?

转载 作者:行者123 更新时间:2023-12-04 14:56:01 26 4
gpt4 key购买 nike

当我创建一个新窗口时,使用 Add Item... 对话框,我创建的窗口,例如NewWindow , 不继承自 Window。它只与类型 Object 具有相同的接口(interface).一个例子:

我有下面的弹出窗口代码。代码只看到 IHavePassword成员,而不是 `LoginPopup' 的其他成员,就像它的控件一样。

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

哦,这也是必要的 XAML:
<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>

属性 Me 上的 IntelliSense列出 IHavePassword 的成员,例如:

enter image description here

我希望看到控件和基础 Window这里的成员,不是界面的那些。我该如何解决这个问题?

最佳答案

我想你只是忘了用你的命名空间包围这个类:

Namespace ApptEase.Client.Prism.Views
Public Class LoginPopup
Implements IHavePassword

'...

End Class
End Namespace

关于.net - 为什么我创建的新 WPF Windows 不是从 Window 继承的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40215567/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com