This is a migrated thread and some comments may be shown as answers.

Change control from unselected TabItem

3 Answers 126 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Vlad
Top achievements
Rank 1
Vlad asked on 12 Jun 2014, 10:54 AM
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?

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 17 Jun 2014, 09:03 AM
Hi Vlad,

I am not sure that I fully understand your scenario, this is why I would ask you to elaborate more on your scenario. Can you please answer the following questions:
  • Where are you placing the imageControl and the pipeControl?
  • What types are those controls?

Also it will be helpful if you can provide me with an isolated project which demonstrates the issue. This will help me in better understanding your case and assist you further.

Thank you in advance for the cooperation.

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Vlad
Top achievements
Rank 1
answered on 17 Jun 2014, 09:42 AM
Hi Martin. Thank you for answer.
I added file where i placed controls. modulCalculationDefect.pipeControl in Tab1. 
When I select Tab1 and click Button imageControl has image modulCalculationDefect.pipeControl, if I select Tab2, image doesn't reload.

Property IsContentPreserved fix this problem.
0
Martin Ivanov
Telerik team
answered on 17 Jun 2014, 12:33 PM
Hi Vlad,

I am happy to hear that you resolved the issue. Please don't hesitate to contact me again if you need any further assistance.

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
TabControl
Asked by
Vlad
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Vlad
Top achievements
Rank 1
Share this question
or