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.
Related
I am currently working on a WPF project in C# using MVVM. In this project I have a list box that loads a user control for each row of data in my items source.
The user control that gets added for each item in my collection also contains a list box that is filled from a database. This second list box often grows and therefore makes each item larger than the view of the first listbox.
My question is, how to I make my listbox have smooth scrolling. Right now it jumps from the top of one item the the top of the next. Since each item is bigger than the view of the listbox I need to be able to scroll without jumping from the top of each item to the next.
I have used a scrollview to achieve this but the list box then intercepts the mouse wheel event and will not allow me to scroll without hovering over the scroll bar.
Is there a better way to do this?
UPDATE:
I can get smooth scrolling using the scrollview control but I cannot scroll while my mouse is inside the scrollview. I have to have my mouse over the scrollbar in order to scroll.
It is like something is intercepting my mousewheel event.
I was able to achieve what I was trying to do by using a ItemsControl rather than the ListBox. It loaded just like the ListBox control and pulled all of my data into it and let the ScrollView handle the scrolling. It did not intercept the mousewheel even like the listbox did.
If you do not need to be able to select an item, I highly recommend using the ItemsControl.
You can set on the Listbox the following Property ScrollViewer.CanContentScroll="False".
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.
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
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.
Does anyone have any ideas on how I can remove the focus rectangle from a silverlight textbox? (I'm talking about the blue rectangle that appears when you click on the texblock to start typing)
I'm looking through the default style and template for the textbox but can't seem to figure out which element to tweak.
Thanks!
In the template you will find a border called FocusVisualElement. In the base and Unfocused Visual State it has an opacity of 0%. In the focused Visual state it has 100% opacity. You can simply delete the FocusVisualElement if you don't want any border indicating the focus.
This probably looks weird when the MouseOverBorder still appears so you might want to delete that too from the Template, however move the ContentElement it holds to the parent Grid first.
Alternatively you could set the Opacity to 0% for these borders in all states.