Edw*_*uay 6 wpf xaml user-controls
我正在重建我在WPF视频的可下载代码中找到的WPF幻灯片放映应用程序结构.
有一个Presentation类,它具有一个INotifyPropertyChanged属性"CurrentSlide",当您单击下一个/上一个按钮时它会发生变化,并在Frame元素中动态显示.
下载的代码将Pages加载到此框架中,但我尝试加载UserControls似乎也能正常工作,实际上我找不到任何区别.
有没有人知道将Pages或UserControl加载到XAML Frame元素中的任何差异?
<Window x:Class="TestFull8229.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:TestFull8229.Commands"
xmlns:viewModels="clr-namespace:TestFull8229.ViewModels"
Title="Main Window" Height="400" Width="800">
<Window.Resources>
<viewModels:Presentation x:Key="presentation"/>
</Window.Resources>
<DockPanel>
<StackPanel>
<Viewbox Stretch="Uniform">
<Frame Width="800" Height="600"
Source="{Binding Path=CurrentSlide,
Source={StaticResource presentation}}"/>
</Viewbox>
</StackPanel>
</DockPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)
页面设计在导航容器中,因此它具有title属性和对导航服务的访问权限.但正如您所指出的,UserControl可以加载到一个框架中,也可以加载任何有效的WPF"内容".Page也可以作为PageFunction的基类,这对于创建向导等结构化导航非常有用.
哦,还有一件事......在没有主机应用程序的情况下,可以在Internet Explorer中加载页面.换句话说,IE可以像Frame或NavigationWindow一样充当页面的导航容器.
| 归档时间: |
|
| 查看次数: |
3461 次 |
| 最近记录: |