日期:2014-05-18  浏览次数:20841 次

关于WPF中控件的一些疑惑,求指导(急急急!!!)
我用的环境是vs2010 现在想用wpf实现一个功能就是点击一个button,当前界面会变成灰色透明的,并且灰色的界面上还有一些新的button出现,这类似于2012的popup控件里添加一些button,不知道vs2010中有没有对应的控件提供,还是2010中本来就有popup(但是我在toolbox里没有找到啊。。。),初学者,求指导

------解决方案--------------------
namespace test
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void button1_Click(object sender, RoutedEventArgs e)
{
this.textBox1.Text = "点击按钮随机改变颜色";
Random rand1 = new Random();
this.gird.Background = new SolidColorBrush
(Color.FromRgb(Convert.ToByte(rand1.Next(0, 255)),
Convert.ToByte(rand1.Next(0, 255)),
Convert.ToByte(rand1.Next(0, 255))));
}
}
}




<Window x:Class="test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid Name="gird">
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="311,203,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="192,118,0,0" Name="textBox1" VerticalAlignment="Top" Width="212" />
</Grid>
</Window>

------解决方案--------------------
在布局时将要新加的那几个button隐藏
<Button Height="25" Visibility="Hidden">OK</Button>
点击后将Hidden改为Visible即可