Benglin/Dynamo — pull request #186 by aosyatnik (2014-11-08 12:31:25+00:00)
Title: DUI: class button bug(not highlighted)

I assume, that Ben has big screen :) That's why he cannot reproduce this bug.

Start state
SelectedIndex = -1
![image](https://cloud.githubusercontent.com/assets/8158404/4963885/d55c5ffc-6733-11e4-80ce-bda3a8cea0b8.png)

Open looong class details
SelectedIndex = 1
![image](https://cloud.githubusercontent.com/assets/8158404/4963890/6158f4f2-6734-11e4-8f32-d97ef7d98d60.png)
![image](https://cloud.githubusercontent.com/assets/8158404/4963894/ab042dd8-6734-11e4-99b6-7ce424e9b36b.png)

Select class button, that is under number 5 now (i.e. File). But you have to make place under File shorter, so that class detail doesn't have enough space to expand.
SelectedIndex = 4.
As well as class details don't have space, scroll viewer repaints itself. And in this place occurs Selection 2 times. First time, when SelectedIndex = 4 and second time, when SelectedIndex = 6(class details).
![image](https://cloud.githubusercontent.com/assets/8158404/4964118/29ceaf7c-6752-11e4-9bb1-a8484abbc805.png)

This fix will work just in case, when scroll viewer repaints and selects class details. But the less class details have place to expand, the greater selected index scrollviewer generates for the second time.

I'm sure the best fix is next: if item, that generated selection event, is pressed class button, then everything works as usual. But if selection event generator is scrollviewer, then we should select class, that was selected before. Unfortunately, I couldn't find how to check it... (e.OriginalSource and e.Source are equal)
All in all, this fix is better than nothing...

Reviewers
@Benglin ,@vmoyseenko, please take a look.

P.S. I'd better talk about it with video.
P.S. P.S. and I tried out use selected index for visibility, it doesn't work, because problem is not in visibility... Problem is in selected index itself.

[Old PR](https://github.com/Benglin/Dynamo/pull/68)