Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
Org Chart Node loses changes on Redraw
posted

Hello all, I'm working with my first org chart and it's not behaving.  I have a tree of nodes that have a template:

 

            <DataTemplate x:Key="ScreenDataTemplate">

                <StackPanel Orientation="Vertical" Width="Auto" Height="Auto" Background="#533090">

                    <ListBox ItemsSource="{Binding DerivedScreens}" BorderThickness="1" BorderBrush="Black" Margin="0"

                             Background="#F0E91B" HorizontalContentAlignment="Stretch">

                        <ListBox.ItemTemplate>

                            <DataTemplate>

                                <TextBlock Name="text" Loaded="SubScreenLoaded" Text="{Binding Name}" FontWeight="Bold" FontSize="16" Foreground="#533090" Margin="0" >

                                    <TextBlock.Resources>

                                        <Storyboard x:Name="fadeOutStory">

                                            <DoubleAnimation Storyboard.TargetName="text"

                                                Storyboard.TargetProperty="Opacity" From="1.0" To="0.25" Duration="0:0:1" />

                                            <ColorAnimation Duration="0:0:01" To="#BEBEBE" 

                                                            Storyboard.TargetName="text"

                                                            Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" 

                                                            />                               

                                        </Storyboard>

                                        <Storyboard x:Name="fadeInStory">

                                            <DoubleAnimation Storyboard.TargetName="text"

                                                Storyboard.TargetProperty="Opacity" From="0.25" To="1.0" Duration="0:0:1" />

                                            <ColorAnimation Duration="0:0:01" To="#533090" 

                                                            Storyboard.TargetName="text"

                                                            Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" />                               

                                        </Storyboard>

                                    </TextBlock.Resources>

                                </TextBlock>

                            </DataTemplate>

                        </ListBox.ItemTemplate>

                    </ListBox>

                </StackPanel>

            </DataTemplate>

 

Based on another input, I run the story for a textblock.  However, if I zoom in on the tree and the node happens to go off the page, the story effects are removed when I zoom back out.  I've spent hours with the LayoutUpdated() method for the TextBlock and have not come up with a good solution.  In the code behind, I am keeping all of the textblocks in a dictionary when they are loaded so that I can iterate through them later.  I can post more code as needed.

 

Parents
  • 140
    posted

    More testing has found that the TextBlock is recreated whenever it is scrolled off the page.  That took me longer than it should have to figure out, but truly frustrating.

    So if I can't keep a reference to a textblock, what would be the best way to get to all of them if they are created in a template for each node?  Is there a way to get the contents of an OrgChartNode if it is created based on a template?

Reply Children