Search code examples
c#lightswitch-2012

SetBinding() on Custom Image Control


I'm stuck on the SetBinding method.

I would like to have 2 kinds of icons in the table, there will be a boolean property and the shown icon will depend on this property. Here is an example :

The problem is that I can´t change the icon. I've tried to google it for about 3 hours, without success.

My idea was to put there Image control and than change the source dependenig on property, but i couldnt find out how to change image source.

So I tryed to create custom sample with image template and SetBinding and here I am stuck...

  int index = 0;

  foreach (var item in this.VidContentItems) {
    if (item.Active == false) {
        this.FindControlInCollection("TrueOrFalse", 
            this.VidContentItems.ElementAt(index)).SetBinding(?????????);
    }
    index++;
  }

Or maybe I'm totally wrong...


Solution

  • OK i solved it like this: I created a table where was just one image item and i add a control image viewer to the grid of the target table, then i made loop and if the value was false i hided the control.. looks easy but this wasnt possible when i was trying to put there just image control, becouse visibility couldnt be changed for specific control , only for all controls...that stacked me a lot..never use image control!!!

    partial void VidContentItemsGrid_Activated() {
      int index = 0;
      foreach (var item in this.VidContentItems) {
        if (item.Active == false) {
          this.FindControlInCollection("TrueIconInd", this.VidContentItems.ElementAt(index)).IsVisible = false;
        }
        index++;
      }
    }