我有边框,2个按钮和2个jpg文件。
这是我的第一个按钮的代码:
private void Button1_Click(object sender, RoutedEventArgs e)
{
Uri uri = new Uri(@"C:\Users\abc\Documents\t1.jpg", UriKind.Relative);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.UriSource = uri;
bi.EndInit();
ImageBrush ib = new ImageBrush(bi)
{
Stretch = Stretch.UniformToFill,
AlignmentX = AlignmentX.Center,
AlignmentY = AlignmentY.Center
};
myBorder.Background = ib;
}
这是我的第二个按钮的代码:
private void Button2_Click(object sender, RoutedEventArgs e)
{
File.Copy(@"C:\Users\abc\Documents\t2.jpg", @"C:\Users\abc\Documents\t1.jpg", true);
}
我在做什么: