I have a WapPanel in my Xaml code.
What kind of items exactly i can add into it?
I know that I can add some Shapes to draw, but I want add and show some Lable or TextBlock with those shapes. How can I do this?
Wrappanel uses UIElementCollection for its children so you can add any UIElement
So basically you can add any
Control (TextBox, Label etc), Shapes, Lines, pretty much anything except Windows
Related
I have a DataGrid, on the scrollbar I would like to put a marker that shows what items are selected. How would something like this be accomplished?
Have had a look around for similar questions and tutorials with no luck.
In my opinion you should create a ControlTemplate for the scrollbar, in which the PART_Track part should be customized (e.g. by adding small rectangles at the different positions). Here you can find the default style and template for the ScrollBar.
You also have to add a new AttachedProperty to the ScrollBar class, so you have some place to store the positions you would like to mark.
Maybe it is better and easier to create a custom control, which is based on the ScrollBar, and add the required properties there. You still have to create a custom template for that control of course.
And finally, to apply a custom ScrollBar Style only to DataGrids see this question.
I have a panel, which I add controls programmatically to it. I want each control stay in a far from other controls and not stay on top of them.
for this purpose I can calculate a position for each control based on Panel's size, but it seems a bit odd.
Is there a way to make controls be added in a line and when it ended they be added in another line?
You can use a FlowLayoutPanel to achieve what you're describing. It's under Containers in the ToolBox. Set the direction to horizontal and it will flow from left to right, and wrap when it needs to.
I believe the WrapPanel class does what you're describing in WPF. Or the FlowLayoutPanel in WinForms.
You have a few options. You can use one of the containers such as FlowLayoutPanel or TableLayoutPanel. You can also nest them in each other. And you have to set the Margin property for each control you add to the containers.
Sadly the Windows Forms technology lacks on this part a little, while WPF has a very rich layout system. Even somethings like Margin doesn't always work as expected.
I am using C#, Silverlight, WP7.
I have been going over Metro Grid Helper (see this link) as I'm also interested in doing an overlay on an existing app. Basically I want to highlight an area, which would add a Rectangle on the overlay.
The difference is that I would like the overlay to scroll with the page, so that the Rectangle would stay in place over an item (like a TextBlock) underneath. And I am confused as to how to do it.
Any suggestions as to what methods or properties or events I should look into for this?
Thanks in advance.
As I am still learning how everything works in Silverlight, I figured this one out today.
The MetroGridHelper class that is linked in the original question adds the overlay objects to be children of the main Grid of the page. This means that no matter what the other controls are for the application (like a Pivot, Panorama, or ScrollViewer), the overlay objects will not move.
Thus, to get the objects to scroll (or swipe with a Pivot or Panorama), the objects need to be the children of the control. So inside the main Grid, look for the control and make that the parent of your objects.
I have an application that loads a XAML file, and shows it in a ContentControl. What I also want to implement is a way to go over the XAML code that was loaded to the control and populate a listbox with the names of the Canvases I find.
The main task of this tiny application is to enable the user to change colors of specific canvases and their elements. Meaning that I have, for example 10 canvases, each containing some <Path> elements. I want to give the user a list of the canvases that were found in the XAML code, and for each canvas the user will be able to change its fill color (for example), if the user changes the fill color of a specific canvas, the child elements of that canvas will change their "Fill" attribute to the selected color as well.
I didn't find a way to iterate through the Canvases or the Path elements, so if anyone have a way to do this I would be glad to hear.
Thanks!
You seem to need to traverse the logical children tree of a given control. For this, you need to use LogicalChildren property recursively.
You can find more information on the element trees in WPF here.
Just ran into a bunch of random but probably very simple questions while learning to work with WPF. If anyone can answer any of these it would be most appreciated.
I have a Rectangle that I styled to my liking, and then a StackPanel that I am actually placing the content (bunch of labels) in. It looks like Rectangle doesn't have a closing statement so how can I make it the parent of the StackPanel (I want the panel to move with it)?
I need to display text (labels) in a table form. It will only be two columns, and 8 rows (row count may change). I initially looked into just using a Grid, but as this is a intended for Layouts, it didn't work as expected. I also checked out DataGrid, but this seems confusing and overly complicated for my needs. Is there any simple Table style element I can use?
I have some Animated Expanders and I want to give the other UI content elements in my application a similar looking title bar. I haven't seen any sort of element for this, so I am wondering if I just need to use a Label or something and style it as close as possible to match, or if something already exists that I should use instead. If I need to use a label, what is the proper way to group/attach it with the element that it is the title bar for?
Do any controls exist for WPF that would allow for a Mac style menu bar? Something similar to where the icons move and expand as they are mouse over.
I have a grid that has two expanders (one above the other) with Height="Auto", and two rows set to Height="Auto" so that when the top is minimized, the bottom one moves up to close the gap. I am using a MinHeight right now to make sure they are at least somewhat expanded, but I would like to make them take up the full 100% of the Grid height. What should I do for this?
A rectangle cannot have child content, a better approach might be to use a Border, you can use this as that parent of your stackpanel, applying a Background and BorderBrush to make it look like a rectangle.
For a simple table layout Grid is the way to go. Is your problem that you need it to be dynamic? If so, you can create multiple grids with SharedSizeGroup on the columns to make them look like a single grid. See: How to align separate Grids created via templates along their columns / rows?
Learn about creating your own templates!
Not that I know of, but it would be relatively simple to do, create a storyboard that scales the item on mouse over.
No idea ... running out of steam!
As Andrzej Nosal mentioned, these really should be separate questions!