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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:26:52+00:00 2026-06-11T10:26:52+00:00

All – Need some insight into this issue. I have created a sample project

  • 0

All –

Need some insight into this issue. I have created a sample project to isolate the issue on one of my projects. I am trying to set the background of my Border based on a certain value in the model (Int/String/Enum).

The issue I am having is:

1) I believe the source in the DataTrigger Binding is being set – but I am still getting this error:
personId property not found on ‘object’ ”String’. BindingExpression:Path=personId; DataItem=’String’ (HashCode=1896530089); target element is ‘Border’ (Name=”); target property is ‘NoTarget’ (type ‘Object’)

2) I was doing this on int (or string) just to make the concept work. But realistically I need to make this of the Enum value. any suggestions on this will also help.

Here are the code snippets:

Person.cs

public class Person
{
    public int personId { get; set; }
    public string personName { get; set; }
    public Gender personType { get; set; }

    public enum Gender
    {
        Male,
        Female
    }
}

PersonViewModel.cs

public class PersonViewModel
{
    private ObservableCollection<Person> _people;

    public ObservableCollection<Person> people
    {
        get
        {
            return _people;
        }
    }

    public PersonViewModel()
    {
        _people = new ObservableCollection<Person>()
        {
            new Person()
            {
                personId = 1,
                personName = "John",
                personType = Person.Gender.Male
            },

            new Person()
            {
                personId = 1,
                personName = "Mary",
                personType = Person.Gender.Female
            },
        };
    }
}

PersonView.xaml.cs

public PersonView()
    {
        InitializeComponent();
         var personvm = new PersonViewModel();
        DataContext = personvm;
    }

PersonView.xaml

 <Window.Resources>
    <Style x:Key="BorderGradient" TargetType="{x:Type Border}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Source=people, Path=personId}" Value="1">
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.511,0.957">
                            <GradientStop Color="LightGray" Offset="0.55" />
                            <GradientStop Color="Black" Offset="1.3" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Source=people, Path=personId}" Value="2">
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.511,0.957">
                            <GradientStop Color="LightGray" Offset="0.55" />
                            <GradientStop Color="Yellow" Offset="1.3" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Window.Resources>

<Border CornerRadius="15,15,15,15" Style="{StaticResource BorderGradient}" >
    <Grid Width="Auto" MinWidth="750" Height="Auto" MinHeight="600">

<!-- Logic in VM where visibility would be set through VM -->

        <StackPanel Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top" Visibility="To be set" >
            <loc:MaleView/>
        </StackPanel>

        <StackPanel Grid.Row="1" HorizontalAlignment="Center"  Visibility=" to be set">
            <loc:FemaleView />
        </StackPanel>
    </Grid>
</Border>

enter image description here

  • 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-11T10:26:53+00:00Added an answer on June 11, 2026 at 10:26 am

    people is an observable collection, which is what you’re binding to in your datatrigger. The ObservableCollection doesn’t have a property named “personId”.

    It would probably be better to have a DataTemplate for your PersonViewModel

    <DataTemplate DataType={x:Type vm:PersonViewModel}">
    
       <Grid Background="Red">
             .. Template For PersonViewModel Here ..
       </Grid>
    
       <DataTemplate.Triggers>
          <DataTrigger Binding="{Binding Path=personId}" Value="1">
             .... do stuff
          </DataTrigger>
       </DataTemplate.Triggers>
    </DataTemplate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All -- I have these two methods in one of my classes: public static
All, I have some script tags that are not working in Wordpress. If I
All, I'm using wordpress with this and for some reason the eventDrop stopped working.
All, In my Lex file we recognize some operators as Tokens some of this
All I have found about this is that there are inconsistencies among different web
All my unit test classes have been created by Visual Studio 2008 from a
all.I'm a beginner of Mysql and I have one simple question here. I want
All this might look too trivial but read it through - I have simple
All is in the question i have tried this : $('#my-div').css('box-shadow'); but it returns
All, I have to create a single database which has a basic schema. This

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.