I have a PivotControl with bindings. Everything worked well until I added a pivot two pivots with the same title, let’s call them C and C’, and A an B two different pivots, ordered like this: AC’BC. Now, when I try to go from B to C everything is OK. But when I go from A to C, it does strange things: doesn’t move, moves the titles but not the content… weird.
I debugged the SelectionChanged event in the PivotControl, and it’s even weirdest. It’s called two times: the first, a transition from C to another pivot and then another call which contains the right transition, from A to C.
I’ve tried everything. The databinding is a list of structs, like this:
struct Resource
{
public someenum Type;
public string Data;
public string Identifier { get {...} set {...} }
public UserToken User;
}
The title of the pivot is set by a IValueConverter, which takes the string Identifier (which is a function of Type, Data and User) as the parameter. I changed it to make the titles always different, but it still does not work. For example, when Type and Data are the same there are error, although Identifier and User are different.
I have written both operators == and != for Resource, and also for UserToken. They behave as they should, but still does this weird transition.
Just found the answer. After a lot of googling, I noticed that maybe GetHashCode had something to do in this mess. I modified the definition of getHashCode in the struct and, voilá! It works smoothly 🙂
Just a tip: to get a good GetHashCode function return a XOR of the volatile parameters of the function. In my case, the code was this: