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 8530409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:14:38+00:00 2026-06-11T09:14:38+00:00

I have an editor view that can be used for multiple edited objects. The

  • 0

I have an editor view that can be used for multiple edited objects. The view model for multiple objects provides a property like Field1Multiple of type bool for each field that needs to be handled. In this case, it’s only ComboBox controls for now. Whenever multiple differing values shall be indicated for that field, a certain style should be applied to that control which is defined in App.xaml. That style changes the background of the control to visualise that there is no single value that can be displayed here.

I’ve tried with this XAML code:

<ComboBox
  ItemsSource="{Binding Project.Field1Values}" DisplayMemberPath="DisplayName"
  SelectedItem="{Binding Field1}">
  <ComboBox.Style>
    <Style>
      <Style.Triggers>
        <DataTrigger Binding="{Binding Field1Multiple}" Value="true">
          <Setter
            Property="ComboBox.Style"
            Value="{StaticResource MultiValueCombo}"/>
        </DataTrigger>
      </Style.Triggers>
    </Style>
  </ComboBox.Style>
</ComboBox>

But it doesn’t work because I cannot set the Style property from inside a Style. If I use triggers directly on the control, there may only be EventTriggers, no DataTriggers, the compiler says.

How can I set the control’s style based on a binding value? Or, how can I set a certain style for a control if a binding value is true?

  • 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-06-11T09:14:39+00:00Added an answer on June 11, 2026 at 9:14 am

    (EDIT to full solution)

    You can use converter:

      public class AnyIsMultipleToStyle : IValueConverter
        {
            public Style NormalStyle { get; set; }
    
            public Style MultiStyle { get; set; }
    
    
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                if (value != null)
                {
                    IList<SampleClass> list= value as IList<SampleClass>;
                    if (list!=null)
                    {
                        if (list.Any(i => i.Multi))
                            return MultiStyle;
    
                    }
    
                }
                return NormalStyle;
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
    

    And in your xaml:(You indicate normal style and multistyle to converter)

     <Window.Resources>
    
            <Style x:Key="MultiValueCombo"  TargetType="{x:Type ComboBox}">
    
                <Setter Property="Background" Value="Olive" />
            </Style>
    
            <Style x:Key="NormalCombo"  TargetType="{x:Type ComboBox}">
                <Setter Property="Background" Value="Red" />
            </Style>
            <my:AnyIsMultipleToStyle x:Key="AnyIsMultipleToStyle1" MultiStyle="{StaticResource MultiValueCombo}" NormalStyle="{StaticResource NormalCombo }"  />
    
    
    
    
    
        </Window.Resources>
        <Grid>
    
            <ComboBox    ItemsSource="{Binding Items, ElementName=root}"  >
                <ComboBox.Style>
                    <Binding Converter="{StaticResource AnyIsMultipleToStyle1}" Path="Items" ElementName="root" >
    
                        </Binding>
                </ComboBox.Style>
    
            </ComboBox>
        </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that contains two @Html.DropDownListFor helpers: <div class=editor-field> @Html.DropDownListFor(model => model.Employee,
I have a model like so: return new MyViewModel() { Name = My View
I have an abstract generic view-model that I use as a base-class for several
I have the following in my Razor view for an editor template in my
I have an editor which is in my window that contains a wrapping iframe
I have an editor I am attempting to emulate that has some very nice
i have an editor that is basic microsoft actions: createlink bold etc. i made
I have an editor that built as follows: EditorBuilder builder = context.Html.Telerik().Editor() .Name(ID) .Encode(false)
Hi I have text editor widget in smalltalk (visual works) that returns a text
I have a MySQL View that is perfectly working: SELECT `t`.`TraderId` AS `TraderId`,`t`.`ShopName` AS

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.