I have a pretty vague description of something I'd like to do, but not entirely sure if it's possible. Well, more accurately not entirely sure of the best way to go about it.
Say I have a single ScrollView and my device is in landscape mode. I have 15 Label objects each on their own line so most of them are off the screen. The user can scroll up and down as you would expect. That's all fine.
For talking sake let's assume that we can only fit 5 Label objects on the screen at any one time. How would I go about ensuring that the middle item of text (the third) on screen at all times has a larger font size? I.e. if the user continues to scroll down the fourth item would become the new centre item and thus be enlarged. Even better, the first and fifth items would be even smaller.
Does that make any sense?
It's kind of like on an iPhone when you're selecting a Month, it's a spinner effect where the middle item (the one that is selected) is always highlighted.
This isn't something you're going to get out of the box. You can either create a custom control and relative custom renderer and build it all out manually, or you could tap into the ScrollView.Scrolled event, then look at the ScrollView.ScrollY value, and then iterate your Labels manually adjusting the FontSize property based on some calculations of how close they are to the scroll position.
Related
I'm developing a windows form application using c#. How can I set a space between items in a checked list box?
You can't, increasing the font size is all you got. Not exactly a control that's suitable for a touch screen. You can re-implement it with ListBox.DrawMode and ControlPaint.DrawCheckBox().
The better selection here is a ListView with View = Tile, easy to hit with your thumb when you make the tile big enough. You can't use ListView.CheckBoxes anymore, using an icon is a good choice. Also automatically takes care of the user only selecting one item.
Looks like you could go with a ListView (which always always always ist the better choice anyway) and a (dummy) imagelist. See
here and here.
Just tried it and it's really easy: Add an imagelist to your form; set its imagesize width to something small and its height to your liking and apply it as the listview's stateimagelist. No need for any actual images.
No need to go for tiles and you could add prices in a 2nd column, even with a different font.. ListView rules ;-)
Let us see the final result! Yumm!!
Under the Behavior Properties, look for ColumnWidth
I am trying to write a XAML UI in WPF where the main window container (a panel) would host children.
The tricky part is I want the children to resize when the window resizes (e.g. when it's being maximized on a screen) and I want them to occupy the maximum of the available space without stretching.
But at the same time I would like them to be allowed to wrap like a wrap panel when possible.
I have designed a quick mockup for easier understanding.
Image mockup on Imgur (25.2KB)
The top one shows a panel hosting 3 elements which all share the same width and the same height. Two are on the first line, the third one takes advantage of the 2nd line to display.
If all were displayed on the first line, they would be of a smaller width.
The bottom one shows a panel hosting 8 elements which all share the same width and the same height (smaller than in the first mockup so they can fit in one screen). The first two lines have 3 elements each while the last line has only 2.
My initial idea was to use a Stackpanel but they strech your child elements and, as far as I know, they don't allow dynamic sizing of their children depending on the number of elements.
Then I had a look at the wrappanel which does the wrapping very nicely but requires you to set the children size in order to do its magic (I might have missed something but I couldn't find a way around it).
Do you have any idea how I could implement this behaviour while keeping my pannel flexible?
The application which is going to use it will have a different number of children to put in the panel depending on the user's settings.
Ah, I forgot to mention that there should obviously be no vertical scrolling, everything should fit on one screen like a dashboard. That's the point of this panel, make sure that everything fits but displays as big as possible, with no distortion.
If you have any question, just ask.
Thank you for your help.
I have created a CheckedListBox control with 4 elements in C#. Multicolumn is set to true. As soon as I make the height of the control small enough to contain only a single row, I can no longer interact with the control with the cursor when I execute the program. If I make the height one unit (pixel?) larger, so that there are 2 columns of 2 rows, behavior returns to normal.
When the cursor cannot interact with the CheckedListBox, I can still tab to it, toggle between its elements with the arrow keys, and check/uncheck elements with the space bar. I just cannot use the cursor.
Looks like a bug to me... I'm experiencing the same thing occasionally. It happens when (1) the CheckedListBox is 1 row high, and (2) the items in it extend ANY past the right edge of the control. If the control is made a little wider, the mouse clicking works again. (You can test that theory by anchoring the CheckedListBox Left/Right and resizing the form. Now it works, now it don't.)
Seems like setting the width to be total column width + 4 also works.
There is a minimum width such that all columns are fully displayed that must be met before you can interact with it via mouse cursor.
Hello I've got a loop that adds some drop down items to a Tool Strip:
usersToolStripMenuItem.DropDownItems.Add(ss);
However this list is going to be long. Is there any way to confine the size of the drop down box (which currently takes up the height of the screen)?
On another note, I've noticed it doesn't support scrolling, is that doable?
No possible.
Hans Passant:
It is already confined, it ran out of screen. Click the little triangle at the bottom to scroll. Usability demands you start using sub-menus.
I don't like the default ToolTip behavior. First, I don't like that, after tooltip is shown for "AutoPopDelay" miliseconds, it disappears and don't appear anymore if you move the mouse over the control again. Second, I don't like that AutoPopDelay is limited to 5000 miliseconds.
I found one way to make tooltip always reappear on mouse move over control, even if it was shown for a time exceeding AutoPopDelay value: I call toolTip.Hide() in MouseLeave handler. This way tooltip will appear again on mouse over.
But I haven't found a simple way to make tooltip stay shown for longer time (longer than maximum 5000 miliseconds). If I call toolTip.Show() in MouseEnter handler, then toolTip is shown in not good position. I like the position in which it shows automatically :)
So, what can you suggest?
Use the Show method to control the length of time (it is not limited to 5000ms).
There is a signature for Show that does not require that you set the relative coordinates and there is one that will take the coordinates if you want to fine-tune things. In your case you will need to pass coordinates (if you don't like what it automatically gives you). I do not believe there to be an alternative...