none
What is the recommended way of dealing with the lack of IMultiValueConverter

    Question

  • As IMultiValueConverter is missing, what is the recommended way of dealing with problems that require an IMultiValueConverter?

    Thursday, July 04, 2013 12:16 AM

Answers

  • IMultiValueConverter is WPF only, and there is a long history of alternative solutions for Silverlight. Search for those and you'll find a number of ideas.

    Commonly you will bind to an object which composes the multiple properties so a single converter has access to everything it needs. There are several Silverlight helper objects that should be fairly straightforward to port for Windows Store apps.

    --Rob

    Thursday, July 04, 2013 12:51 AM
    Owner

All replies

  • IMultiValueConverter is WPF only, and there is a long history of alternative solutions for Silverlight. Search for those and you'll find a number of ideas.

    Commonly you will bind to an object which composes the multiple properties so a single converter has access to everything it needs. There are several Silverlight helper objects that should be fairly straightforward to port for Windows Store apps.

    --Rob

    Thursday, July 04, 2013 12:51 AM
    Owner
  • I agree that if the convertor is dealing with a single object you don't need a multivalue convertor - you just pass the object.  But we don't have a single object with comprises these multiple properties. 

     

    I have a List<Hippo> hippos

     

    public List<Hippo> hippos
    
    public class Hippo(){
    public int Length{ get; set;}
    public string Name {get; set;}
    }

    I have an itemscontrol

    <ItemsControl x:name="HippoCage" ItemsSource="{Binding Hippos}" ItemTemplate="{StaticResource HippoTemplate}">
    <ItemsControl.ItemTemplate>
       <ItemsPanelTemplate>
         <Canvas>
         </Canvas>
    </ItemsPanelTemplate>
    </ItemsControl.ItemTemplate>
    </ItemsControl>

    And then I have the HippoTemplate datatemplate, which, in the WPF version of my app, uses multi value convertors to pass in the actualWidth of the HippoCage, and the Hippo Length property to set various properties of the UI rendering of the hippo object, to ensure that the hippos are represented in proportion to the rendered size of the hippocage, amongst other interesting things.

    I'm aware that WinRT doesn't have an IMultiValueConvertor.  I was asking for a recommended way of approaching the problem.

    Jon

    Thursday, July 04, 2013 2:03 AM
  • Hi Jon,

    The same solutions used to solve this for Silverlight will also apply to Windows Store apps.

    --Rob

    Thursday, July 04, 2013 5:11 AM
    Owner