Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Xamreportviewer display challenge
posted

Hello Team,

I want sample application to meet the following criteria.

In xamreportviewer there are 2 fields. If the values are same in 2 fields then in 3rd field value should be "true". otherwise value must be false. The "false" value should display in red color. In the 3rd field if one of the value is false then there should be a label on top of 3rd field and it should display value as "false".

How to achieve this?

Could you help,please?

  • 29610
    Offline posted

    Hello Gaurish,

    I would like you to take a look at the attached sample project on this matter. In the attached sample project, I have constructed a table with three fields. Two of the fields are bound back to an ObservableCollection that makes up the data context of the table. The third uses an expression for it's Text property designated as the following, where "Number1" and "Number2" are the two properties on the data item:

    =(Fields.Number1 = Fields.Number2)

    The above will show true or false, based on whether or not the first two fields are equal. For the red coloring of the field, you can craft a similar expression for the Foreground property of the third field, but using an If-statement, like so:

    =If(Fields.Number1 = Fields.Number2, "Black", "Red")

    The above will check whether or not the Number1 and Number2 properties are equal. If they are, the foreground will be colored Black, and if not, it will be Red.

    Finally, I added a Label above the third field that has the same data context as the table, and has its text set to "False". The foreground of this Label is set to be Red, but it's visibility is bound to yet another expression. This expression looks like the following:

    =If(All(Fields.Number1 = Fields.Number2), False, True)

    The above expression checks if all of the Number1 fields equal the Number2 fields. If they are all equal, then False is returned to the Visibility of the Label. If not, there must be one inequality, and so True is returned to the Label.

    I have attached a sample project to demonstrate the above. I hope it helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    Reporting2016.zip