Change control from unselected TabItem

4 posts, 0 answers
  1. Vlad
    Vlad avatar
    6 posts
    Member since:
    Jan 2014

    Posted 12 Jun 2014 Link to this post

    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?

  2. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 17 Jun 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vlad
    Vlad avatar
    6 posts
    Member since:
    Jan 2014

    Posted 17 Jun 2014 in reply to Martin Link to this post

    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.
  5. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 17 Jun 2014 Link to this post

    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.
     
Back to Top