Binding - Border

Hello,

I know it is a wpf question, but maybe have you an idea.

The aim of my code is to decide what color used for border and first gradientstop of the background of my node between predefined option colors and data override color.

When I use this code on “go:NodeShape” object, all is ok
but on “Border”, at the first time loading the UserControl, the border is not setted. I’ve made some trace and I’ve seen that the binding for border is called twice (and the last call, with Options.Color unset… )

Well, that’s puzzling, because, when I add a new node (from palette), the borderbrush is at this time well defined !

Thanks
Aurore

(ps: delete my message if it is not a GoDiagram framework)

This one work as expected:

<go:SpotPanel Style="{StaticResource SpotPanelStyle}"
                          Name="oNodeBorder"
                          go:Part.DropOntoBehavior="AddsLinkFromNode"
                          Background="{Binding Path=Part.IsDropOntoAccepted,
                                   Converter={StaticResource convBoolBrush}}">
                <go:NodeShape go:NodePanel.Figure="Dodecagon" 
                                  StrokeThickness="1">
                        <go:NodeShape.Stroke>
                            <SolidColorBrush>
                                <SolidColorBrush.Color>
                                    <MultiBinding Converter="{StaticResource convQDColor}">
                                        <tools:ParentDataBinding AncestorType="{x:Type v6Concept:MC_QDiagram}"
                                                                 Path="Options.ColorPart" />
                                        <Binding Path="Data.Item.Color" Converter="{StaticResource convDrawingMediaColor}"  />
                                    </MultiBinding>
                                </SolidColorBrush.Color>
                            </SolidColorBrush>
                        </go:NodeShape.Stroke>
                        <go:NodeShape.Fill>
                        <LinearGradientBrush StartPoint="0,0.5"
                                             EndPoint="1,0.5">
                            <LinearGradientBrush.GradientStops>
                                <GradientStop Offset="0" >
                                    <GradientStop.Color >
                                         <MultiBinding Converter="{StaticResource convQDColor}">
                                                <tools:ParentDataBinding AncestorType="{x:Type v6Concept:MC_QDiagram}" Path="Options.ColorPart" />
                                                <Binding Path="Data.Item.Color" Converter="{StaticResource convDrawingMediaColor}"/>
                                        </MultiBinding>
                                    </GradientStop.Color>
                                </GradientStop>

                                <GradientStop Offset="1.00"
                                              Color="#ffffffff" />
                            </LinearGradientBrush.GradientStops>
                        </LinearGradientBrush>
                    </go:NodeShape.Fill>
                </go:NodeShape>
     ...
</go:SpotPanel>

This one doens’t work :

<go:SpotPanel Style="{StaticResource SpotPanelStyle}"
                          Name="oNodeBorder"
                              go:Part.DropOntoBehavior="AddsLinkFromNode"
                          Background="{Binding Path=Part.IsDropOntoAccepted,
                                   Converter={StaticResource convBoolBrush}}">
 <Border CornerRadius="15"
                        BorderThickness="1"
                        HorizontalAlignment="Stretch">
                        <Border.BorderBrush>
                            <SolidColorBrush>
                                <SolidColorBrush.Color>
                                    <MultiBinding Converter="{StaticResource convQDColor}">
                                        <tools:ParentDataBinding AncestorType="{x:Type v6Concept:MC_QDiagram}"
                                                                 Path="Options.ColorGroup" />
                                        <Binding Path="Data.Item.Color"
                                                 Converter="{StaticResource convDrawingMediaColor}"/>
                                    </MultiBinding>
                                </SolidColorBrush.Color>
                            </SolidColorBrush>
                        </Border.BorderBrush>

                            <Border.Background>
                        <LinearGradientBrush StartPoint="0,0.5"
                                             EndPoint="1,0.5">
                            <LinearGradientBrush.GradientStops>
                                <GradientStop Offset="0" >
                                    <GradientStop.Color>
                                        <MultiBinding Converter="{StaticResource convQDColor}">
                                                <tools:ParentDataBinding AncestorType="{x:Type v6Concept:MC_QDiagram}" Path="Options.ColorGroup" />
                                                <Binding Path="Data.Item.Color" Converter="{StaticResource convDrawingMediaColor}"/>
                                        </MultiBinding>
                                    </GradientStop.Color>
                                </GradientStop>
                                <GradientStop Offset="1.00"
                                              Color="#ffffffff" />
                            </LinearGradientBrush.GradientStops>
                        </LinearGradientBrush>
                    </Border.Background>
            ...
</Border>
</go:SpotPanel>

So the DataTemplates are the same except for the use of a Border instead of a NodeShape? And they both have the expected sizes? It’s just the brushes that aren’t right when you use the Border?

Oh, wait, the second one uses Path=“Options.ColorGroup”, whereas the first one uses Path=“Options.ColorPart”. Was that intentional?

Are there are any interesting trace listener messages in the Output window?

[QUOTE=walter]So the DataTemplates are the same except for the use of a Border instead of a NodeShape? And they both have the expected sizes? It’s just the brushes that aren’t right when you use the Border?
[/quote]

Yes they are…

It’s intentional, but ColorGroup and ColorPart are well defined.

No, only that he can’t perform the last binding because no ancestor of type MC_QDiagram is found…

Aurore

I agree that it’s very puzzling that it should work in one DataTemplate but not the other one. I can’t explain it. Maybe it’s because we explicitly invalidate the visual for the NodeShape, causing the brush binding to be evaluated later, although I don’t understand why that would make a difference.