1

WPF 相当新,我想创建一个向导。

所以我有一个名为 WizardUC.x​​aml 的 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 上有按钮来控制 Back 和 Next 等。

任何帮助将不胜感激!:)

4

0 回答 0