views:

22

answers:

1

Hi,

I'm trying to figure out how to call a wcf in an asynchronous pattern in xaml tooltip object. so far I got the following code inside my combobox item template

the combo box has several itemNames pulled from a database and a toolip appears whenever mouse is hovered on any of the items. I'm trying to show more information on the hovered item inside that tooltip. this is where i need to call the wcf service in an asynchronous fashion. could u please share your ideas with me on this matter.

<ComboBox.ItemTemplate>
    <DataTemplate>
       <TextBlock x:Name="tbTradeName" Text="{Binding}" />
       <DataTemplate.Triggers>
            <Trigger Property="IsMouseOver" SourceName="tbTradeName" Value="True">
                <Setter TargetName="tbTradeName" Property="ToolTip">
                     <Setter.Value>
                         <ToolTip>
                           <ToolTip.Content>
                              <StackPanel Width="300" Height="150" Background="Orange">
                                  <TextBlock Text="{Binding}" />
                                  <StackPanel Width="300" Height="100">

                                     <!-- I need the content from wcf service here -->

                                  </StackPanel>
                              </StackPanel>
                            </ToolTip.Content>
                         </ToolTip>
                      </Setter.Value>
                   </Setter>
                  </Trigger>
               </DataTemplate.Triggers>
             </DataTemplate>
           </ComboBox.ItemTemplate>

at the moment im thinking of using the code behind to track some event on the combobox item and then somehow load content into the panel. I will try that one, but im not very sure about the idea.

Thank you.

A: 

I'd bind tooltip to a property of object implementing INotifyPropertyChanged. So when asyn result is received from wcf it updates object property,NotifyPropertyChanged is triggered and WPF binding updates tooltip. Trigger wcf async request for tooltip value in code-behind in Opened event of Tooltip.

Andrii V
Thanks, I'll try this one. I was able to go halfway on this matter using follwing approach. I created a object data provider in the window.resources section and used it to call the relavent method( happen in synchronous mode) and get the list of data objects from the service. in the object data provider I've put an empty string parameter, and then bound this dataprovider to the dataContext of a stack panel in the Data template section shown above. What I need to do is to change the string parameter on the object data provider when hovered on the text block element in data template.