开发者

asynchronously call a wcf service in xaml

I'm trying to figure ou开发者_StackOverflow社区t 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜