Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 215819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:30:23+00:00 2026-05-11T18:30:23+00:00

Trying to determine if it is possible to bind the SelectedValue of a ComboBox

  • 0

Trying to determine if it is possible to bind the SelectedValue of a ComboBox to the inputs of multiple ObjectDataProviders with XAMAL Bindings.

I looked at MultiBinding but that appears to be grouping multiple controls together, not exactly what I’m looking to day.

I’d like to be able to have the ComboBox (locations) change the TextBlock (deviance) which it does AND to call the ObjectDataProvider (CommentProvider) to update the TextBox (locationComments).

This is fairly straightforward in a code-behind but would prefer to not go this route as a learning experience.

XAMAL CODE

<Window.Resources>
    <ObjectDataProvider x:Key="LocationProvider"
        ObjectType="{x:Type srv:ServiceClient}"
        IsAsynchronous="True"MethodName="GetAssignedLocations" />
    <ObjectDataProvider
        x:Key="DevianceProvider"
        ObjectType="{x:Type srv:ServiceClient}"
        IsAsynchronous="True" MethodName="GetPercentChange">
        <ObjectDataProvider.MethodParameters>
            <system:String>Location1</system:String>
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>
    <ObjectDataProvider
        x:Key="CommentProvider"
        ObjectType="{x:Type srv:ServiceClient}"
        IsAsynchronous="True"
        MethodName="GetCommentByBusinessUnit">
        <ObjectDataProvider.MethodParameters>
            <system:String>Location1</system:String>
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>
</Window.Resources>

<ComboBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="locations"  VerticalAlignment="Top" ItemsSource="{Binding Source={StaticResource LocationProvider}}"
              DisplayMemberPath="BuName" SelectedValuePath="BuKey"
              SelectionChanged="locations_SelectionChanged">
        <ComboBox.SelectedValue>
            <Binding Source="{StaticResource DevianceProvider}"
             Path="MethodParameters[0]"   
                 BindsDirectlyToSource="True" 
                 Mode="OneWayToSource" />
        </ComboBox.SelectedValue>
<TextBlock Name="deviance" Height="23" Margin="0,0,645,17" Width="40" Text="{Binding Source={StaticResource DevianceProvider}}" IsEnabled="False" />

<TextBox Height="23" Margin="0,0,181,17" Name="locationComments" Width="350" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:30:24+00:00Added an answer on May 11, 2026 at 6:30 pm

    You’re on the right track with the MultiBinding.
    The key is to use a MultiValueCoverter in conjunction with the MultiBinding.

    <MultiBinding Converter="{StaticResource Coverter_LocationMultiConverter}"
                  Mode="OneWayToSource">
                    <Binding Source="{StaticResource DevianceProvider}"
                             Path="MethodParameters[0]"
                             BindsDirectlyToSource="True"
                             Mode="OneWayToSource" />
                    <Binding Source="{StaticResource CommentProvider}"
                             Path="MethodParameters[0]"
                             BindsDirectlyToSource="True"
                             Mode="OneWayToSource" />
                </MultiBinding>
    

    Where we were binding to just one thing before, now we are binding it to both ObjectDataProviders. The key factor that lets us do this is the converter:

    public class LocationMultiCoverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members
    
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            return new object[] { value, value };
        }
    
        #endregion
    }
    

    Because we just need the same value in both places the CovertBack method is quite simple, however I’m sure you can see that it could be used to parse some complex stuff and pass back different components to different places in the UI.

    Using this converter we can also try out a small sample, using two text boxes instead:

    <Window x:Class="Sample.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Sample"
        Title="Window1"
        Height="300"
        Width="300">
    <Window.Resources>
        <local:LocationMultiCoverter x:Key="Coverter_LocationMultiConverter" />
    </Window.Resources>
    <Grid>
        <StackPanel>
            <TextBlock x:Name="uiDeviance" />
            <TextBlock x:Name="uiComment" />
            <ComboBox x:Name="uiLocations"
                      Height="23"
                      HorizontalAlignment="Left"
                      VerticalAlignment="Top"
                      SelectedValuePath="Content">
                <ComboBoxItem>1</ComboBoxItem>
                <ComboBoxItem>2</ComboBoxItem>
                <ComboBoxItem>3</ComboBoxItem>
                <ComboBoxItem>4</ComboBoxItem>
                <ComboBoxItem>5</ComboBoxItem>
                <ComboBox.SelectedValue>
                    <MultiBinding Converter="{StaticResource Coverter_LocationMultiConverter}"
                                  Mode="OneWayToSource">
                        <Binding ElementName="uiDeviance"
                                 Path="Text"
                                 BindsDirectlyToSource="True" />
                        <Binding ElementName="uiComment"
                                 Path="Text"
                                 BindsDirectlyToSource="True" />
                    </MultiBinding>
                </ComboBox.SelectedValue>
            </ComboBox>
        </StackPanel>
    </Grid>
    

    (The Converter in my example exists in the Window’s code behind as a separate class)
    And as you can see testing this out it will update both TextBoxes when the SelectedValue changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to determine whether it's possible to create css for an element that
I'm trying determine if it's possible in C# to have a generic class that
I am trying to determine all the possible words that are next to a
I am trying to determine if it is possible to get a list of
I am trying to determine if it is possible to use Generics in the
I am trying to determine if it is possible to add a concatenated string
I'm trying to determine the relationship between default values and the has_foo() methods that
I've been looking around trying to determine some Hibernate behavior that I'm unsure about.
I am trying to determine the end of a foreach loop that is seeded
I'm using a maven plugin and I'm trying to determine that default goal it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.