Hey all,
Is there a way I can bind the DisplayMemberPath of combobox to a function? The object with which I am currently working has three properties I wish to use for presentation; FirstName, LastName, and MiddleName.
I wrote a static method in a Formatting class to handle it. This method is called FullName and accepts three string arguments.
Is there a way I can call Formatting.FullName and pass in the three arguments from my Person object in order to display the formatted full name into the combobox items?
Thanks in advance,
Sonny
UPDATE: I've added the following XAML to the resources section of my page:
<ObjectDataProvider ObjectType="{x:Type business:Formatting}" x:Key="formatter" />
<ObjectDataProvider ObjectInstance="{StaticResource formatter}" MethodName="FullName" x:Key="nameFormatter">
<ObjectDataProvider.MethodParameters>
<system:String>Bloggs</system:String>
<system:String>Joe</system:String>
<system:String>Q</system:String>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
And my combobox XAML now looks like this:
<ComboBox Height="23" HorizontalAlignment="Left" Margin="467,72,0,0" Name="cboDistrictAttorney" VerticalAlignment="Top" Width="120" SelectedValuePath="Id" SelectedValue="{Binding DistrictAttorneyId}" DisplayMemberPath="{Binding Source={StaticResource nameFormatter}}" />
And the end result is that I have a combobox full of blank items.