コード例 #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (e.OriginalSource is Button button && button.Tag is string tag)
     {
         var index = tag.Value <int>() + 1;
         FrameDemo.Navigate(index >= _pageList.Count ? _pageList[0] : _pageList[index]);
     }
 }
コード例 #2
0
    public FrameDemoCtl()
    {
        InitializeComponent();

        AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(Button_Click));

        _pageList = new List <Page>();
        for (var i = 0; i < 5; i++)
        {
            _pageList.Add(CreatePage(i));
        }

        FrameDemo.Navigate(_pageList[0]);
    }