0

I am not able to get MultiBinding on Ellipse.Fill working correctly. I do have (single) Binding working correctly, plus MultiBinding on Ellipse.Tooltip:

<Ellipse Margin="210,56,0,0" Fill="{Binding InspectorPC, Converter={StaticResource statusButtonConverter}, Mode=OneWay}">
    <Ellipse.ToolTip>
        <MultiBinding Converter="{StaticResource statusStringConverter}" Mode="OneWay">
            <Binding Path="InspectorPC"/>
            <Binding Path="InspectorPCPing"/>
            <Binding Path="InspectorPCReadHD"/>
        </MultiBinding>
    </Ellipse.ToolTip>
</Ellipse>

but I would like something like:

<Ellipse Margin="210,56,0,0">
    <Ellipse.Fill>
        <MultiBinding Converter="{StaticResource statusButtonConverter}" Mode="OneWay">
            <Binding Path="InspectorPCPing"/>
            <Binding Path="InspectorPCReadHD"/>
        </MultiBinding>
    </Ellipse.Fill>
    <Ellipse.ToolTip>
        <MultiBinding Converter="{StaticResource statusStringConverter}" Mode="OneWay">
            <Binding Path="InspectorPC"/>
            <Binding Path="InspectorPCPing"/>
            <Binding Path="InspectorPCReadHD"/>
        </MultiBinding>
    </Ellipse.ToolTip>
</Ellipse>

(Obviously statusButtonConverter would need to be changed from IValueConverter to IMultiValueConverter, but that is not the issue.)

Conrad
  • 2,197
  • 28
  • 53

1 Answers1

2

If this isn't working, it suggests a problem in your statusButtonConverter implementation.

A simple example shows no problem applying a MultiBinding to Ellipse.Fill:

<Window x:Class="WpfTest.FillMultiBinding"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:WpfTest2"
        Width="320"
        Height="160">
  <Window.Resources>
    <l:BrushPartsConverter x:Key="brushPartsConverter" />
  </Window.Resources>
  <Window.DataContext>
    <l:FillViewModel />
  </Window.DataContext>
  <Ellipse>
    <Ellipse.Fill>
      <!-- Dodger + Blue = DodgerBlue -->
      <MultiBinding Converter="{StaticResource brushPartsConverter}" Mode="OneWay">
        <Binding Path="Part1" />
        <Binding Path="Part2" />
      </MultiBinding>
    </Ellipse.Fill>
  </Ellipse>
</Window>
public class FillViewModel
{
    public string Part1 => "Dodger";
    public string Part2 => "Blue";
}

public class BrushPartsConverter : IMultiValueConverter
{
    private static readonly BrushConverter InnerConverter = new BrushConverter();

    public object Convert(object[] values, Type type, object p, CultureInfo c)
    {
        if (values?.Length == 2)
            return InnerConverter.ConvertFrom("" + values[0] + values[1]);
        return DependencyProperty.UnsetValue;
    }

    public object[] ConvertBack(object value, Type[] types, object p, CultureInfo c)
    {
        return new[] { DependencyProperty.UnsetValue };
    }
}

Screenshot

Post the code for your converter and binding context (view model), and we'll see what we can do.

Mike Strobel
  • 25,075
  • 57
  • 69
  • Haha Intellisense has failed me! The code I wanted to use actually works perfectly. When I went to start typing "MultiBinding" within `Ellipse.Fill`, Intellisense did not offer it as an option, so I figured it was not a valid tag. – Conrad Jan 22 '18 at 16:16
  • 1
    @Conrad Whoops :). – Mike Strobel Jan 22 '18 at 16:17