binding to a function call instead of property?

Hi,

If I have following function

class LanguageHandler

{

public static string GetString(string key)

{

}

}

Is anyway I can binding a textblock - text to the GetString function

thanks/chong



Answer this question

binding to a function call instead of property?

  • Johan Stenberg

    But how do you specify parameter for the function in the binding

    thanks/chong


  • MAMMOTH_MK

    I thought you could specify a MethodName in ObjectDataProvider, no

    <ObjectDataProvider x:Key="Code1DSKey" d:IsDataSource="True" ObjectType="{x:Type MyNameSpace:Code1}" MethodName="MyFunction"/>

    ....

    <TextBlock Text="{Binding Source={StaticResource Code1DSKey}}" />

    Thanks,
    -Unni



  • Vijay Subramani

    Hi, Unni:

    Thanks for the reply, I think it is one step close to my need. The problem is

    how to specify parameter in and pass it to ObjectDataProvider methodparameters

    <TextBlock Text="{Binding Source={StaticResource Code1DSKey}}" />

    thanks

    chong


  • ThisIsBrianS

    Thanks for the suggestion, I have already read that article but that doesn't solve my problem. In the article, it explains how to use objectdataprovider and bind too fields together.

    In my case, I just want to bind one control-text to a objectprovider and pass value to the objectprovider throught parameter.

    chong


  • boest02

    Ah, sorry, I missed that. I used Reflector to find out:

    xmlns:sys
    ="clr-namespace:System;assembly=mscorlib"

    ...

    <ObjectDataProvider x:Key="Code1DS" d:IsDataSource="True" ObjectType="{x:Type Bug:Code1}" MethodName="MyFunction">
    <ObjectDataProvider.MethodParameters>
    <sys:String>Foo</sys:String>
    </
    ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>

    Thanks,
    -Unni



  • digital rebel

    Hi Chong,

    I would like to understand what you're trying to do a little better. You say you would like to bind one control to an ObjectDataProvider that takes a parameter to the method, but that is exactly what Unni shows in his markup sample. If you give me some more details, I will give it a shot.

    Thanks!

    Bea



  • Lee Stallworth

    Hi Chong,

    Take a look at Bea Costa's March 19th blog posting (under "Binding to a method"). Hope this helps!

    http://www.beacosta.com/Archive/2006_03_01_bcosta_archive.html

    Thanks,

    Tina



  • binding to a function call instead of property?