Search code examples
c#wpfxamlmultibinding

How to MultiBinding too GeometryGroup


I have a working MultiBinding with a Path.Data (Path here is System.Windows.Shapes.Path). The Converter return type is System.Windows.Media.PathGeometry.

<Path.Data>
  <MultiBinding Converter="{StaticResource ResourceKey=ToPathGeometryMultiConverter}">
    <Binding Path="A"/>
    <Binding Path="B"/>
    <Binding Path="C"/>
  </MultiBinding>-->
</Path.Data>

Now I want to change the structure a bit and add several geometries in a GeometryGroup. I don't know the syntax how to add MultiBinding here.

<Path.Data>                    
  <GeometryGroup>       
    <PathGeometry> 
     <!-- HOW CAN I MULTIBIND HERE --> 
    </PathGeometry>
  </GeometryGrounp>
<Path.Data>

Whatever I tried I always got a compile error.


Solution

  • You may bind the PathGeometry.Figures property and have a converter that returns a PathFigureCollection, but I'm afraid you have to live with the fact that the VS Designer complains about the XAML.

    <Path.Data>
        <GeometryGroup>
            <PathGeometry>
                <PathGeometry.Figures>
                    <MultiBinding Converter="{StaticResource PathFiguresConverter}">
                        <Binding Path="A"/>
                        <Binding Path="B"/>
                        <Binding Path="C"/>
                    </MultiBinding>
                </PathGeometry.Figures>
            </PathGeometry>
        </GeometryGroup>
    </Path.Data>