z order of surface listbox item - wpf

I am trying to bring the focus on the clicked item of the surface listbox. For WPF I had a similar post and it worked after setting the trigger property of .
The full xaml code is available at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5d486826-9a72-4769-bd09-ff6977e16c30/#cd2cd9af-abbf-40ca-9e30-4684ee2a2eb2
I tried doing the same in the xaml code for a surface button which is put as item in surface listbox, nothing happens. Basically, my listbox contains surface buttons and when any button is clicked, it scales up i.e. the size of it increases. The only issue is that next item overlaps the scaled item because of the z-order issue. For the normal WPF listbox and button control above code did the trick but its not happening for surface application.
Would appreciate any help/directions in this issue.

Got it working.. Had posted on MSDN and it finally worked by setting the zIndex of the surfaceListbox instead of the content of the item which was a surfacebutton.
http://social.msdn.microsoft.com/Forums/en-US/surfaceappdevelopment/thread/970877bd-2960-4f0e-a203-1d357bbd55ce/#4a08e54b-5055-4a66-ad75-762ee88ef303

Related

WPF Adorner Overlay Problem

I am trying to achieve functionality similar to that of a Popup, without using a Popup, but instead adorning my ContentControl with a basic adorner. Basically, I want the ContentControl to have an "overlay" effect, whereby it is the topmost object, above all other elements - similiar to that of the Popup control.
Here is the problem that I am running into, and I am hoping that someone can point out where I am going wrong:
I have a stand grid with two row definitions. The first row contains a UI element - for example, a rectangle. The second row contains a custom control that I have developed to emulate the functionality of a "drawer" sliding out. Basically, when I click on button, I am going to animate a TranslateTransform to "slide" my ContentControl "up". This works fine - except that it gets cropped underneath the rectange in the first row of the grid. If I remove the row definitions in the grid, then when the desired behavior is achieved - the ContentControl is moved "up" and partially "on top" of the rectangle. The rectangle is merely a place holder for what I am trying to achieve. I basically want to have a drawer type control that can slide out and be on top of all other controls.
I am somewhat new to using the Adorner class, so, I am hoping that someone can please point out where I am going wrong.
Thanks.
Chris
Change the parent of the adorner to the full grid, and not just your control. If you put a control in a grid row, and set the adorner to adorn the control, it will usually be clipped to that row because the control is.

WPF popup on ListBoxItem

I have a MiniToolbar popup that shows up at Mouseover on a ListBoxItem, it needs to show just under the item.
(a MouseOver trigger also sets the IsSelected property on the items)
I tried two options :
define the popup on the items DataTemplate
define the popup on the ControlTemplate for the ListBoxItem
Both options work fine, however I was wondering if the popup was recreated each time ??
(please advise)
I think it would be better to define the popup in the ControlTemplate of the containing ListBox rather than the ListBoxItem ?
I tried this, but could not find the binding expression for placement property relative to the SelectedItem (it shows up at the bottom of the ListBox, not bottom of ListBoxItem).
Any suggestions ?
thanks in advance.
Michael.
The popup is created one time for each list box item in both cases.
I would not suggest that you use single popup for all items in the CotnrolTemplate for the list box because it significantly complicates things. But if you still want to do so, you can set Placement="Custom" on you popup and specify CustomPopupPlacementCallback. In that callback you can calculate the placement using the position of currently selected item.

Cant Drag ListBoxItem Adorner outside of ListBox in WPF -ScrollViewerProblem

I am working with a WPF application that uses alot of drag and drop. Everything is working fine, with exception of ListBoxItems. I have a ListBox with ListBoxItems that can be dragged to another target( a StackPanel). The problem is, when I drag the cursor outside the ListBox, I cant see the Adorner that I have setup with the ListBoxItem?
I know this is a common problem, but I am just not sure how to fix it. Is there something that I need to do to allow me to drag outside of the ListBox control?
Below I have attached what the UI looks like so far. As you can see, there is a ListBox on the bottom left. When I drag an item, the adorner appears, and follows the cursor around while the cursor is over the ListBox, but if I try to move the cursor away from the listbox, the Adorner seems to almost go under the other controls(zIndex?).
Edit - Solution
I have changed the code to handle the AdornerLayer relative to the window as oppose to relative to the AdornedElement
So I changed
layer = AdornerLayer.GetAdornerLayer(_originalElement);
to
layer = AdornerLayer.GetAdornerLayer(this);
This solved the problem of the ScrollViwer clipping the AdornerLayer
The ListBox (or, to be specific, the ScrollViewer within the listbox) clips any adorners attached to it's children. This is done to ensure that adorners for items scrolled out of view are not shown. To get around this, you need to explicitly put thing in the Window's adorner and not that of the listbox or listboxitem

silverlight 3 listbox item highlight versus selected

I have a listbox and am attempting to select and item in code. Sometime one item is highlighted, that is it is background is colored blue, but a different item has a square blue box around the it (no highlighting just an hollow outline of a box).
Am I correct in saying one is "highlighted" and one is "selected" and do I have them correctly identified?
Should this be happening... that is these 2 things being out of sync?
Thanks
Cody
Just fought this issue.
Although the listbox scrollviewer will auto scroll too the selected item in the listbox the first item would have focus and as you discribe keyboard interaction then operated with the first item in the list not eh selected item.
For us the fix was
this.MyListBox.UpdateLayout();
this.MyListBox.Focus();
this.MyListBox.SelectedItem = MyObject;
this.MyListBox.ScrollIntoView(this.MyListBox.SelectedItem);
The order of the actions seems very important.
This was using the ListBox internal scrollviewer.
The item with the blue highlighted background is the SelectedItem. The item with the blue rectangle is the item that currently believes it has the focus.
Ordinarily the Focus rectangle the selected fill are found together because the selected item usually changes with a mouse click which also brings the focus to the same element. However its possible for example that code may change the selected item whilst the ListBox still has the focus. In that case the selected highlight will move the newly selected item but the focus rectangle will remain where it is. (Note to the pendatic I'm describing what appears to the user not how things actually work under the hood).
For an insight on what is going on see the ListBoxItem style in the ListBox Styles and Templates documentation.

WPF How to animate selection box movement of ListView?

I want to animate movement of a selection box in ListView so it will move from old selected item to currently selected.
I don't even know where to start - could someone please share ideas how to achieve that or it's impossible to do in WPF.
Animate selected item of wpf listbox
Check this. This could give you a start.
After that try animating your border background color to get a virtual translation animation.

Resources