Some visibility bindings only change when the corresponding link is selected

Hello Walter,

I have some links that are supposed to depict pipes for air ventilation. These pipes have some additional information that can be hidden or shown (this is necessary for short links as you have trouble accessing the connected nodes being overlapped by the info text otherwise). The template is rather complex so I’ve added some comments to show what’s going on.

<DataTemplate x:Key="PipeLinkTemplate">
  <!-- Status will be set on various actions and define whether the link is selectable -->
  <go:LinkPanel go:Node.LayerName="{Binding Path=Data.Layer.Id}"
                go:Link.Visible="{Binding Path=Data.IsVisible}"
                go:Link.Selectable="{Binding Path=Data.Status, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static style:PartStatus.Default}}">
    <!-- Set link directly to port -->
      <go:Route FromEndSegmentLength="0"
                ToEndSegmentLength="0" />
      <!-- Status also sets color and cursor
           Stroke size can be set by a dropdown in a ribbon bar -->
      <go:LinkShape Style="{StaticResource StatusLinkStyle}"
                    StrokeThickness="{Binding Path=Data.StrokeSize}" />

        <!-- This is the additional info that is displayed
             The Visibility is set to a property in the view model rather than the LinkData -->
        <StackPanel go:LinkPanel.Orientation="Upright"
                    Visibility="{Binding DataContext.PipeInfosHidden, RelativeSource={RelativeSource AncestorType={x:Type go:DiagramPanel}}, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=True}">
          <!-- This shows the length of the link with 1m being 100px
               FontSize changes when stroke size is increased -->
          <TextBlock Style="{StaticResource StatusLinkTextStyle}"
                     Text="{Binding Path=Data.DisplayLength, StringFormat={}{0} m}"
                     FontSize="{Binding Path=Data.FontSize}"
                     Margin="0,5,0,0" />
          <!-- This StackPanel shows either a simple textblock containing the pipe's diameter or a dropdown to select the diameter when hovered. This is followed by the display of a lock that indicates whether automatic pipe diameter calculation considers to change this pipe's diameter on calculation.
                     This lock can have four different states that each displays a different vector graphic.
                     1. If the lock is open, the pipe diameter can be changed by the algorithm. The lock can be opened by clicking on it, as it is actually a button.
                     2. If the lock is closed, it can't be automatically changed by the algorithm. The lock will be automatically closed when the user selects a diameter from the dropdown.
                     3. Color indicates whether the lock can be used by the user. In case of the lock being greyed out the dropdown is not displayed either so it can't be changed. -->
          <StackPanel Orientation="Horizontal"
            <Button MinHeight="25"
                    FontSize="{Binding Path=Data.FontSize}">
                <Style TargetType="Button">
                   <Setter Property="Template"
                           Value="{StaticResource TextTemplate}" />
                   <!-- As you can see, the mouse over effect to show the diameter combo box only works if the status is Default or Selected -->
                         <Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True"></Condition>
                         <Condition Binding="{Binding Path=Data.Status}" Value="{x:Static style:PartStatus.Default}"></Condition>
                       <Setter Property="Template"
                               Value="{StaticResource ComboBoxTemplate}" />
                       <Setter Property="Grid.ColumnSpan"
                               Value="2" />
                         <Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True"></Condition>
                         <Condition Binding="{Binding Path=Data.Status}" Value="{x:Static style:PartStatus.Selected}"></Condition>
                       <Setter Property="Template"
                               Value="{StaticResource ComboBoxTemplate}" />
                       <Setter Property="Grid.ColumnSpan"
                               Value="2" />
             <Button Click="Button_Click"
                     Style="{StaticResource StatusLockStyle}"
                     Tag="{Binding DataContext.NodeSource, RelativeSource={RelativeSource AncestorType={x:Type go:DiagramPanel}}}"
                     Width="{Binding Path=Data.FontSize}"
                     Height="{Binding Path=Data.FontSize}">

To display the pipe info a DevExpress ribbon button sets the PipeInfosHidden value of the view model to which the node is bound.

And here’s the problem. Some of the pipes don’t show the pipe infos when the button is pressed. As soon as the pipes are selected, though, the pipe infos pop up. Do you have any idea why this might happen?

You may need to call Part.Remeasure on each of those Links when you change properties such as PipeInfosHidden.

That worked, thank you.