WPF相当新,我想创建一个向导。
所以我有一个名为WizardUC.xaml的UserControl包含:
namespace ClientApplication.View.Wizard
{
/// <summary>
/// Interaction logic for WizardUC.xaml
/// </summary>
public partial class WizardUC : ItemsControl
{
public WizardUC()
InitializeComponent();
}
List<UserControl> userControls = new List<UserControl>();
int currentUserControl = 0;
private void ItemsControl_Loaded(object sender, RoutedEventArgs e)
{
foreach (UserControl i in Items)
{
userControls.Add(i);
i.Visibility = System.Windows.Visibility.Collapsed;
}
userControls[currentUserControl].Visibility = System.Windows.Visibility.Visible;
}
}
一个名为WizardTest.xaml的窗口,其中包含:
<Window x:Class="ClientApplication.View.TestViews.WizardTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WizardTest" Height="358" Width="351" xmlns:my="clr-namespace:ClientApplication.View.Wizard" xmlns:my1="clr-namespace:ClientApplication.View.Ribbon.CalendarUsercontorls" xmlns:my2="clr-namespace:ClientApplication.View.Ribbon">
<Grid>
<my:WizardUC Height="261" HorizontalAlignment="Left" x:Name="wizardUC1" VerticalAlignment="Top" Width="278">
<my1:DetailToDo HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<my2:UserControlSchadule HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</my:WizardUC>
</Grid>
</Window>
因为你可以看到我在WizardUC中添加了两个UserControl。
基本上我想要的是在ItemsControl上的Usercontrol上使用Buttons来控制Back和Next等。
任何帮助将不胜感激! :)