Hi. I have window with button and RadTabControl with 3 TabItem.
Button has click event
private void BtnPrint_OnClick(object sender, RoutedEventArgs e)
{
Random r = new Random();
var Background = Color.FromArgb((byte)r.Next(255), (byte)r.Next(255), (byte)r.Next(255), (byte)r.Next(255));
Brush brush = new SolidColorBrush(Background);
modulCalculationDefect.pipeControl.Background = brush;
RenderTargetBitmap targetBitmap = new RenderTargetBitmap((int)modulCalculationDefect.pipeControl.ActualWidth,
(int)modulCalculationDefect.pipeControl.ActualHeight, 96d, 96d, PixelFormats.Default);
targetBitmap.Render(modulCalculationDefect.pipeControl);
BmpBitmapEncoder encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
MemoryStream stream = new MemoryStream();
encoder.Save(stream);
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.StreamSource = new MemoryStream(stream.ToArray());
bmp.EndInit();
imageControl.Source = bmp;
}
So when i click button I must change backgroud modulCalculationDefect.pipeControl, make image and view this image in imageControl. This work when select RadTabItem where located modulCalculationDefect.pipeControl. When selected another item image in imageControl doesn't change.
How can I fix that?
Button has click event
private void BtnPrint_OnClick(object sender, RoutedEventArgs e)
{
Random r = new Random();
var Background = Color.FromArgb((byte)r.Next(255), (byte)r.Next(255), (byte)r.Next(255), (byte)r.Next(255));
Brush brush = new SolidColorBrush(Background);
modulCalculationDefect.pipeControl.Background = brush;
RenderTargetBitmap targetBitmap = new RenderTargetBitmap((int)modulCalculationDefect.pipeControl.ActualWidth,
(int)modulCalculationDefect.pipeControl.ActualHeight, 96d, 96d, PixelFormats.Default);
targetBitmap.Render(modulCalculationDefect.pipeControl);
BmpBitmapEncoder encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
MemoryStream stream = new MemoryStream();
encoder.Save(stream);
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.StreamSource = new MemoryStream(stream.ToArray());
bmp.EndInit();
imageControl.Source = bmp;
}
So when i click button I must change backgroud modulCalculationDefect.pipeControl, make image and view this image in imageControl. This work when select RadTabItem where located modulCalculationDefect.pipeControl. When selected another item image in imageControl doesn't change.
How can I fix that?