Creating a custom shaped border - wpf

I need to create a border with some kind of arrow in its edge. This is the picture -
And I need to be able to move this arrow (it points the selected item in a listbox outside the border).
Thanks.

What I have done is to put this triangle as an image in the ListBox (left to the border), and I'm showing it only on the selected item (with DataBinding).
Not to "stright", but works great (after I was sure I wouldn't be able to do that).

Related

wx.ComboBox hides behind other panels

I have been working with wxPython for quite a while now. I have a pretty good handle on most objects, and I've been able to create panel layouts without issue for the most part.
What I'm trying to do here is to display two lists (combo boxes.) One represents the complete list of possible options (on the left) that the user may select and add to the list on the right. The functionality works just fine, but the objects themselves visually become obscured by other panels contained within the same tab of a wxNotebook object (see red rectangle on attached image.)
The top panel is a composite of three panels. The first contains a combo box and some spacers. The second (middle) contains the buttons that allow the user to add/remove items. The third, like the first, is a combo box and some spacers. The middle panel scales fine, but I cannot adjust the height of the combo boxes.
I want the combo boxes to be the wx.CB_SIMPLE layout so that all options are displayed. Ideally, if the number of options exceeds the panel height, I would see a vertical scroll bar.
What would be the easiest way to accomplish this without losing the combo boxes behind other panels?
I don't see a need to have 3 panels nested inside of your notebook page. Instead I would create one panel with nested sizers. You can create one horizontal BoxSizer to hold all the widgets. Then inside of that, you can add the left combobox to the sizer. Next create a vertical sizer that you can put your buttons into (add, remove, clear).
Add that vertical sizer to your horizontal sizer. Now create your right combobox and add it to the horizontal sizer. Now you have the same setup or close to it and you won't have panels crossing over each other.

WPF Ellipse why can I not add a grid?

I have a WPF application. I am trying to create a ellipse toggle button. I wanted to have a textbox in the ellipse with two images next to each other below the textbox. In my other buttons I have added a grid with two rows to achieve this.
However it doesn't like it when I try to add a grid to an ellipse. "The type ellipse does not support direct content". What does this mean? Is it possible to do what I wish?
This particular error really couldn't be too much clearer:
The type Ellipse does not support direct content.
The Ellipse Shape is not a ContentControl. Therefore, it does not have a Content property. This means that you cannot add any content to it.
What you can do is to add a Grid with no columns or rows defined and add your Ellipse into the Grid. Then you can overlay other UI elements in front of the Ellipse, which may appear as if they were inside it.

WPF: Changing the look of a Surface Listbox "click-effect"

I'm changing the look of some Controls that I use in my Microsoft Surface Application at the moment. And today I'm working on a SurfaceListBox.
I have the template for it and already changed background and borders and other stuff.
But I really cannot find where I can change the color of the rectangle that appears on the ListBoxItem when you touch the ListBox. At the moment it's just white and I want to change that.
It's not something like the effect that you can see when the item is selected. I already found that and changed that so my selected item now appears in a different color. But the effect in the second when you touch the item stays white.
So where can I change this effect?
If you mean the bright, white highlight that happens when you press your finger against an item you should look into the SurfaceShadowChrome. It's used by (almost) all surface controls to give feedback when the user is pressing on a control.
It does have a Color property that you can modify to suit your needs. Apart from the color, and the tweaking of corner radius and shadow offset, it's not a very flexible decorator. But hopefully, you'll be able to make it do what you need.

WPF/C#: Images rotating from a listview?

I just want ask for your comments/suggestions on how to create a customized listview (if that's a good implementation) in WPF that displays images coming from a table from a database (more like a playlist) that rotates similar to a film (moving horizontally - on loop)
Any ideas?
If you have a list of Images, you can create an Image control for each one, put each Image control in a horizontal StackPanel, put the StackPanel inside a Canvas (of whatever size of the "film"), and animate the Left property of the Canvas to have the images roll.
Of course, if you need that the images wrap (the first one after the last one), you could forget about the StackPanel and move each Image separately.

Silverlight MouseDragElementBehavior. How to rearrange items after drag and drop?

I have stack panel with custom controls in it. User can add or remove the items.
I have attached MouseDragElementBehavior to each item. So now user can move them within the stack panel.
However the items now are arranged on arbitrary manner. Is a mess really. They stay where the user left them.
What I need now is to make them to be stacked as the stack panel supposed to be... Nicely one by one...
So I need to simply let user change the order of items by using drag / drop operation but items has to be stacked precisely.
There is DragFinished event, but I dont really see how the Behavior moves items. I thought it is Margin it changes but margins stays 0... I dont know what to do next.
Appreciate little help.
MouseDragElementBehavior does its work using a Transform on the RenderTransform property of the attached element (i.e. the one the behavior is applied to) (the exact type of transform depends on the state of the RenderTransform property but it will either be a TranslateTransform or a MatrixTransform).
The transform is not reset when you finish dragging (nor would you want it to be because the element would snap back to its position in the StackPanel when you started dragging) and this is why the element stays where "the user left them".
To change the items position in the StackPanel in the way you are talking about you will have to use the DragFinished event. What you probably want to do is work out where in the StackPanel the element will end up (as a result of the drag, i.e. which element in the panel it will "push" down) then create an animation to animate the element from its current position (where the user released the drag) to that final position in the StackPanel and another animation to move the "pushed" element in to its new position in the StackPanel (VisualTreeHelper can probably help here (I think)). Once those animations are finished just set the new index within the StackPanel for each item and remove the RenderTransform translation.

Resources