使用其他控件作为mahapps metro中转换内容的内容

时间:2015-01-03 17:05:52

标签: c# wpf mahapps.metro

我可以只使用textblock作为mahapps metro中转换控制的唯一内容。我试过这个,但它不能用作例外。我不是一名wpf专家。任何人都可以建议这有什么问题吗?这就是我试过的

    StackPanel sp = new StackPanel();
    Image imgx  = new Image();
    Image imgy = new Image();
    TextBlock tb = new TextBlock();
            if (x == 1)
        {
            x = 0;
            tb.Text = "X = 1";
            imgy.Visibility = Visibility.Hidden;
            imgx.Visibility = Visibility.Visible;
            var uriSource = new Uri("images/blank-cd.png.png", UriKind.Relative);
            imgx.Source = new BitmapImage(uriSource);
            sp.Children.Add(imgx);
            sp.Children.Add(tb);
            SecondcustomTransitioning.Content = sp;
        }
        else if (x == 0)
        {
            x = 1;
            tb.Text = "X = 1";
            imgx.Visibility = Visibility.Hidden;
            imgy.Visibility = Visibility.Visible;
            var uriSource = new Uri("images/placeholder_person.gif", UriKind.Relative);
            imgy.Source = new BitmapImage(uriSource);
            sp.Children.Add(imgy);
            sp.Children.Add(tb);
            SecondcustomTransitioning.Content = sp;
        }

0 个答案:

没有答案