C# 使用其他控件作为内容在mahapps metro中转换内容
我可以只使用textblock作为mahapps metro中转换控制的唯一内容吗。我试过这个,但不例外。我不是wpf专家。有人能指出这有什么不对吗?这就是我尝试过的C# 使用其他控件作为内容在mahapps metro中转换内容,c#,wpf,mahapps.metro,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)
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;
}
删除所有这些内容并使用适当的XAML。@HighCore您的意思是,XAML中的模板选择器?可能与