如何在选择更改时找到所选的Flipview控制索引

时间:2013-05-06 10:38:13

标签: c# windows-8 windows-store-apps winrt-xaml

我正在开发一个应用程序,Flipview控件它有两个flipview项目模板选择更改(flipview)我需要得到flipview的选定索引是可能的。我试过这样的

private void _fvDashboard_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        int index=_fvDashboard.SelectedIndex;
        if (index != -1)
        {
            if (_fvDashboard.SelectedIndex == 1)
            {
                btnScrBoard.Background = new SolidColorBrush(ColorHelper.FromArgb(255, 54, 54, 54));
                btnItem2.Foreground = new SolidColorBrush(ColorHelper.FromArgb(255, 255, 255, 255));

                btnItem1.Background = new SolidColorBrush(ColorHelper.FromArgb(255, 210, 222, 235));
                btnItem1.Foreground = new SolidColorBrush(ColorHelper.FromArgb(255, 0, 0, 0));

                _fvDashboard.SelectedIndex = 1;
            }
            else
            {
                btnItem1.Background = new SolidColorBrush(ColorHelper.FromArgb(255, 54, 54, 54));
                btnItem1.Foreground = new SolidColorBrush(ColorHelper.FromArgb(255, 255, 255, 255));

                btnItem2.Background = new SolidColorBrush(ColorHelper.FromArgb(255, 210, 222, 235));
                btnItem2.Foreground = new SolidColorBrush(ColorHelper.FromArgb(255, 0, 0, 0));

                _fvDashboard.SelectedIndex = 0;
            }
        }
    }

0 个答案:

没有答案