Question: I have a datagrid bound to a list and each cells value is bound to unique booleans.

```
<UserControl.Resources>
    <Style TargetType="{x:Type DataGridCell}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Have1}" Value="True">
                <Setter Property="Background" Value="#263DDE36"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Have1}" Value="False">
                <Setter Property="Background" Value="#26FF5454"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</UserControl.Resources>

<DataGrid ItemsSource="{Binding AuditList}" AutoGenerateColumns="False" >
    <DataGrid.Columns>
        <DataGridTextColumn Header="Art1" Binding="{Binding Have1}"/>
        <DataGridTextColumn Header="Art2" Binding="{Binding Have2}"/>
        <DataGridTextColumn Header="Art2" Binding="{Binding Have3}"/>
    </DataGrid.Columns>
</DataGrid>

```

This works fine but I would like to change the binding "Have1", to the cells current string or bool value.

```
<DataTrigger Binding="{Binding DataCellsValue="True"}" Value="True">
    <Setter Property="Background" Value="#263DDE36"/>
</DataTrigger>
<DataTrigger Binding="{Binding DataCellsValue="False"}" Value="False">
    <Setter Property="Background" Value="#26FF5454"/>
</DataTrigger>

```

How is this achieved? Ideally, I just want to use the one setter for all columns without duplicating setters for each columns cell.

Thanks!

Answer: 
Just use the standard library algorithms 

```
auto end = std::find(std::begin(array),std::end(array),0);
std::reverse(std::begin(array),end);
//And if you only want to print the non-zero values:
size_t effectiveArraySize = end - std::begin(array);

```

---

If the fixed size array is not part of your requirement, you should put your user data in a vector that automaticaly grows as large as you need, instead of using an array that might turn out to be too small:

```
std::vector<int> v;
while(true) {
    int t;
    cin >> t;
    if (t == 0) {
       break;
    }
    v.push_back(t);       
}
std::reverse(v.begin(),v.end());

```

That way, you don't have any sentinel values in your array / vector to begin with.
You need to find the **actual length** of the array, before performing the **reverse** operation, and then use that length for all further operations. 

Like this:

```
int actualArraySize = 0;

while(actualArraySize < arraysize && array[actualArraySize]!=0)
{
 actualArraySize++;
}

int temp;
for (int i = 0; i < actualArraySize/2; i++)
{
  temp = array[actualArraySize-1-i];
  array[actualArraySize - i - 1] = array[i];
  array[i] = temp;
}

cout << "The reverse array: ";
for (int i = 0; i < actualArraySize; i++)
  cout << array[i]<< ' ';
cout << endl;

```

Note that, `actualArraySize` can be less than or equal to `arraysize`, but, not more than it, because of the condition in `while(actualArraySize < arraysize && array[actualArraySize]!=0)`, which means that stop when either a `0` is found or the size of the array is reached.