I want to change from a instance of a class the height of a child.
The problem is, that the canvas did not “saves” it height when running the function Compute_Change_height_of_ressource
.
I have this class
public partial class RessourceTreeViewItem : TreeViewItem {
public int RG_ID { get; set; }
public double height_of_ressource { get; set; }
StackPanel taskPanel { get; set; }
Label taskLabel { get; set; }
public String RGLabeltxt { get; set; }
public Canvas backgroundcanvas { get; set; }
public ScrollViewer scrollViewer { get; set; }
public DateTime startdatetime { get; set; }
public DockPanel panel { get; set; }
public RessourceTreeViewItem(int RG_ID, double dots_per_minute, DateTime startdatetime, DateTime enddatetime, String RGLabeltxt, double height_of_ressource)
{
this.RGLabeltxt = RGLabeltxt;
this.RG_ID = RG_ID;
this.startdatetime = startdatetime;
this.height_of_ressource = height_of_ressource;
this.panel = new DockPanel();
this.panel.HorizontalAlignment = HorizontalAlignment.Left;
this.taskLabel = new Label() {
Content = this.RGLabeltxt
};
this.taskLabel.Width = 40;
this.Margin = new Thickness(-40, 0, 0, 0);
this.backgroundcanvas = new Canvas();
this.backgroundcanvas.Height = this.height_of_ressource;
this.scrollViewer = new ScrollViewer();
this.scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
this.scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
this.scrollViewer.Content = this.backgroundcanvas;
// Add the task label and the scroll viewer to the task panel
this.panel.Children.Add(taskLabel);
this.panel.Children.Add(this.scrollViewer);
this.Header = this.panel;
}
public void Compute_Change_height_of_ressource(double height_of_ressource)
{
foreach (TimeLineItem item in this.backgroundcanvas.Children)
{
item.Compute_Change_height_of_ressource(height_of_ressource);
}
this.height_of_ressource = height_of_ressource;
this.panel.Height = height_of_ressource;
this.scrollViewer.Height = height_of_ressource;
this.backgroundcanvas.Height = height_of_ressource;
}
My Problem is, as when I want to update via Compute_Change_height_of_ressource
, the backgroundcanvas.Height
does not change its height as I see in debug.
All other attributes were changed.
In the visual tree, there is ScrollContentPresenter
the parent of the backgroundcanvas
, which has the old height – how can i change it?