For a day now I'm struggling to solving this issue, regarding scaling a textblock and a textbox upon pinching the scatterViewItem for resizing it.
I've tried putting each of the elements in their viewbox, but also having the whole grid in a viewbox.
The issue is that it(the textbloxk, that is) doesn't scale upon pinching or stretching rather, (dynamically so to speak) - at runtime, or not even upon contact_up.
What actually solves it is simply setting an event handler that fires upon size_changed of the SVI, inside simply paste the code:
{label name}.FontSize *= (double)e.NewSize.Height / (double)e.PreviousSize.Height;
Thanks!
I am assuming you mean that the TextBlock in the window does not scale when resizing the window...? Have you tried putting a ViewBox in a Grid that contains the item you want to resize? If you have the item in a ViewBox, and set the Height and Width of the ViewBox to Auto, is should resize with the window...I hope this helps a little.
Related
I'm having a problem with auto sizing all of the controls on my WPF. I'm able to get them too stay on the side of the screen where I want them, the only problem is that, when I have the window the same size as the editor, it looks perfect, however, when I change too full screen (Has too be full screen), it centers everything rather then stretching too fit across the entire window.
Any idea how I could go about fixing this? I have provided a few photos.
After doing a lot of research, I found putting it in a panel, and then making the panel Anchor too none and then setting the Alignment too none, it fixed the windowed version but not full screen version. Any help would be great.
I'm setting the window too full screen with this.WindowState = FormWindowState.Maximized; if that makes any difference at all?
The grid should help you with that, just define columnas and rows. Then put the controls inside the rows and change the alignment (vertical and horizontal) to stretch and you are done.
You will have a problem with the text size, that need tl be managed in code behind or in your viewmodel
If you want a control to span on múltiple rows or multiple columns use the grid.rowspan and grid. Columnspan properties.
Sorry for the bad formatting, im on the phone
I use a RadGridView (a GridView from telerik libraries) and I resize the rows height for simulate a zoom.
The issue is that the scrollbar values become wrong after a zoom. I receive the values ExtentHeight (total virtual height of my RadGridView) and a VerticalOffset (my position), and both are false.
As I know the individual height of every cells, I can manually calculate the ExtentHeight, but not the VerticalOffset. And the concern is that I have synchronized my grid with a scrollbar which gives a render of the RadGridView, and it can’t be synchronized with these bad values. The only solution is to scroll all the RadGridView, and the scrollbar will be updated with the new heights of its children.
You can see an example in this video, where I scroll after a zoom, and it’s not working. Then I scroll all the grid (with the down arrow), and it works after.
https://youtu.be/QqvTnYK5A6o
So how my scrollbar can automatically updates the values of its content ?
The method scrollBar.UpdateLayout(); doesn't work unfortunaly.
Thanks !
The solution is to set the property EnableRowVirtualization of the RadGridView to false, but it causes a big performance problem unfortunately.
I have 3 buttons in my form. What I need to do is when I make the actual form bigger or smaller, the buttons should change their position and size so they look good, so they wouldn't remain the same size and position. I tried to use the anchors, but that does not work very well. What can I use to solve my problem?
You can check dock and anchor properties
http://www.youtube.com/watch?v=afsx1IJULLI
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock(v=vs.110).aspx
You should set both left and right, or top and bottom anchors to resize control. If you'll set only one anchor from these pairs, then control will be positioned instead of resizing.
Docking will resize control, because it is equivalent of setting three or more anchors.
Try using TableLayoutPanel, put your buttons inside the columns of the table
Look good is different all the time. I like placing buttons in StackPanel and setting AutoSize property to true. This fixes two issues:
If user has 150% font in Windows settings - your UI does not break;
if you resize window to be very small - your buttons do not enforce minimal width/height and adapt to ratio user has chosen
there is a search View ( app is a MVP - PRISM WPF ) which had some issue with scrolling. it took hell of a long time to scroll when you click the scroll bar buttons. Click and dragging the scroll bar was even worse!!
considering i like anomalies, i picked it and started looking into what was going wrong. I suspected many things, but evidently the issue with the datagrid scroll was due to "ScrollViewer.CanContentScroll=True" i removed it and the scrolling was a pleasant experience compared with earlier.
Now i was wondering why my developers had put that property as true, with in couple of mins i found Doing a Page down was scrolling more than a page with out the CanContentScroll property marked true!
Now i need the scrolling to be faster AND i also need page down and page up to scroll as expected! Can some one tell me What I am missing here?? thanks!
I had similar issues with my datagrid : slow scrolling, and also randomly size changing scrollbar.
I did the following:
simplify the templates of the cells (no more nested borders and multiple colors, ToggleButtons instead of CheckBoxes)
in code use frozen colors.
this helped speed things up but did not solve the issue.
Then i set the row / cells templates height and also the RowHeight property, and then it was ok : i had both smooth scrolling and normal scrollbar. So i guess that the DataGrid was unable to compute the size of what remained to be displayed that made both the scroll slow and the scrollbar having changing size.
(Yet the rows / cells were all having same actual height in their templates since they were defined with same controls but Height property was not set...)
Hope that can help.
I've created a user control using WPF and I want to add it to window. I've done that, but I can't make my control have a height higher than the height it has in its own xaml file. My MaxWidth and MaxHeight are both infinity, but I can't make the control any taller than what it is in its xaml file.
To get around this, I have to make all my user control enormous so I'll be able to size them to whatever I want. This doesn't seem right, I have to be missing something.
Removing the height and width is the way to go. The designer(blend) has some special designer width and height properties that they can use to design in, but won't set the height for runtime.
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="412" d:DesignHeight="230"
That is the xaml that will be at the top of the Window/UserControl. This should help explain things.
Why do you want your control to have a height higher than the height it has in its own XAML file? Couldn't you just remove the height in the control's XAML file, and explicitily set the height of the control when you declare it in the other XAML files (or code) that use it?
If I remove the height and width in the controls XAML file I lose the ability to use the designer for my user control. So short answer, that did solve my problem, but now I can't use the designer for user controls. Doesn't seem like I'm any better off.
The problem could be that the inner controls in your user control aren't stretching to your control. Try setting HorizontalAlignment="Stretch" or Width="Auto" on the inner controls, or you could try binding the Width property.
Ok, after some further investigation, I've misspoken. its the Grid thats causing the problem. If I set the grid Width and Heigth to Auto then everything works fine, but I lose the ability to use the designer.
I have all of the alignments set to Stretch for both the Grid and its controls.
So in summary, everything works fine if I set Grid.Width = Auto and Grid.Height = Auto, but when i do that, I lose the ability to use the designer.
I'm not aware of any width/height attributes for the VS designer if that's what you're using. I've used the MinWidth/MinHeight attributes in my xaml pretty effectively, however, to deal with the situation that I think you're describing.