从一个视图模型转到另一个视图模型时,自定义弹出窗口无法正常工作的问题 [英] Problem with custom popup window not working when going from one view model to another and back
问题描述
我在使用MVVM范例的C#中使用WPF在WPF中工作。所以,当我发现这篇文章
WPF中的自定义弹出窗口和MVVM方式时,我非常兴奋,并广泛使用它。
我使用ApplicationView创建我的应用程序来加载我的不同视图模型,每个视图模型都是一个用户控件。因此,每个用户控件左侧都有一个按钮,每个按钮都独立运行。
使用上面文章中描述的自定义弹出窗口时出现问题。当我在一个用户控件中时,弹出窗口工作正常。然后当我点击按钮转到其他用户控件并在那里做任何事情然后回到上一个视图时弹出窗口不再有效。
我已经完成了代码并完成了我能想到的一切,包括修改自定义弹出窗口dll。但没有运气。我相信很多人都使用过这个控件,因为它真的是一个很棒的控件。
希望有足够的人使用这个控件并以类似的方式设计他们的应用程序以便了解我所描述的内容。
我的申请视图是这样的
I am working with WPF in VS 2012 with C# utilizing the MVVM paradigm. So when I found this article
Custom popup and windows in WPF the MVVM way I was very excited and have used it extensively.
I create my applications using the ApplicationView to load up my different view models each of which is a user control. So Each user control has a button on the left and each operates independently.
My problem comes in when using the Custom popup as describe in the article above. The popup works fine when I am in one user control. Then when I click on the button to go to the other user control and do whatever over there and then come back to the previous view the popup no longer works.
I have stepped through the code and done everything I can think of including modifying the custom popup window dll. But with no luck. I am sure many people have used this control because it is really a great control.
Hopefully enough people out there have used this control and design their apps in a similar fashion so as to understand what I am describing.
My application view looks like so
<Window x:Class="PremierCareFinance.ApplicationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PremierCareFinance"
xmlns:cancelled="clr-namespace:PremierCareFinance.CancelledOrders"
xmlns:wpfx="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="Premier Care Finance" Height="800" Width="1280" Icon="finance.ico">
<Window.Resources>
<DataTemplate DataType="{x:Type local:HomeViewModel}">
<local:HomeView />
</DataTemplate>
<DataTemplate DataType="{x:Type local:CustomerViewModel}">
<local:CustomerView />
</DataTemplate>
<DataTemplate DataType="{x:Type cancelled:CancelledOrderViewModel}">
<cancelled:CancelledOrderView />
</DataTemplate>
</Window.Resources>
<Grid>
<DockPanel>
<Border DockPanel.Dock="Left" BorderBrush="Black" BorderThickness="0,0,1,0">
<ItemsControl ItemsSource="{Binding PageViewModels}" >
<ItemsControl.ItemTemplate>
<DataTemplate >
<Button Content="{Binding Name}"
Command="{Binding DataContext.ChangePageCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
CommandParameter="{Binding }" Margin="2,5"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
<ContentControl Content="{Binding CurrentPageViewModel}" />
</DockPanel>
</Grid>
</Window>
那么我的所有观点都是UserControls,我使用了很多标签。
感谢任何帮助
Then all of my views are UserControls and I utilize tabs quite a bit.
Any help is appreciated
推荐答案
这篇关于从一个视图模型转到另一个视图模型时,自定义弹出窗口无法正常工作的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!