0

This is the question I had posted. Now, I am not able to reflect the changes made to the rectangle element in the DataTemplate. I want to scaleX the rectangle depending on some values and conditions in the code-behind. I did the following :

     foreach (var rectangle in FindVisualChildren<Rectangle>(this))
     {
       if (rectangle.Name == "rectangleBarChart" && isRectangle == false)
       {
             rectangle.Fill = Brushes.MediumVioletRed;
             rectangle.Height = 10;
             rectangle.LayoutTransform = new ScaleTransform(2, 1);
             isRectangle = true;
       }
     }

But, the changes are not reflected, it uses the same old DataTemplate. Any hints to refelct the changes to the UI ?

Community
  • 1
  • 1
Robert Langdon
  • 855
  • 1
  • 11
  • 27

1 Answers1

0
rectangle.Fill = Brushes.MediumVioletRed;
            rectangle.Height = 10;
            rectangle.LayoutTransform = new ScaleTransform(2, 1);
            isRectangle = true;
            **rectangle.UpdateLayout();**

Use UpdateLayOut Method to update.I hope this will help.

yo chauhan
  • 12,079
  • 4
  • 39
  • 58