This question already has answers here:
How to refresh by pulling down the items?
(2 answers)
Closed 8 years ago.
I'm using a ScrollViewer and want to know when VerticalOffset's value changes. couldn't find an event. can I detect that?
<ScrollViewer Name="scrollViewer">
</ScrollViewer>
Don't know what you are actually trying to do, but I wrote an article on the Nokia developer site that allows you to track the vertical offset of the scrollviewer and manipulate another UI element.
I guess it has all the needed info for your question?
Take a look at it here http://developer.nokia.com/Community/Wiki/How_to_keep_a_UI_element_in_view_when_scrolling_a_page_in_Windows_Phone
There are 2 important parts in that you must not forget, first in the scrollviewer set the property ManipulationMode to Control
ManipulationMode="Control"
Secondly to get hold of the vertical offset, you'll need to search for the VerticalScrollBar inside the ScrollViewer, like this:
_vBar = ((FrameworkElement)VisualTreeHelper.GetChild(ScrollViewer, 0)).FindName("VerticalScrollBar") as ScrollBar;
_vBar.ValueChanged += _vBar_ValueChangedHandler;
Related
This question already has an answer here:
Propagate ListBoxItem IsSelected trigger to child control
(1 answer)
Closed 3 years ago.
I'm writing a custom checkable ListBox and the items must be checked when an item is selected. The easiest approach I could come up with is to increase the CheckBox height/width (size) to cover the whole ListBoxItem area, however I couldn't manage to vertically align the square and its text, eg:
The red text is somewhat the desired alignment, given its whole area (blue rectangle). What's necessary to achieve this?
Everybody's always gotta try and over-complicate things :)
Try VerticalContentAlignment="Center".
This question already has answers here:
Customizing the TrackBar control in .NET
(2 answers)
How to make an ownerdraw Trackbar in WinForms
(3 answers)
Closed 6 years ago.
I was planning on creating a custom TrackBar class that implements from TrackBar. I want it to look/feel EXACTLY the same, other than a display on the value just to the side of the track itself.
I've been seeing that you can either let the OS draw the control, or allow the user draw it, but then the user must draw EVERYTHING. Is there a way for me to allow the OS draw the control, and then let me draw the value?
EDIT:
The key I want to emphasize is, I want to only add the drawing the value, rather than drawing the whole thing myself.
This question already has answers here:
Custom WPF Slider with image as Thumb
(2 answers)
Closed 7 years ago.
I'm learning C#, and I'm making a WPF Application.
The trouble is:
I have tried, but I don't know how to make a simple image object be a slider.
I have an idea to get values, calculating by the position of image object. I only need help to move the object image by the mouse.
Can you help me?
This is probably not the answer that you wanted, but it is the answer. You need to declare a custom ControlTemplate for the Slider control. This is no task for a new developer really, but there is some help at hand. First, I recommend that you read through the WPF Control Templates - An Overview page on MSDN for some background to this task.
Next, if you're not put off by that read, you can find the default ControlTemplate for the Slider in the Slider Styles and Templates page on MSDN. It's always best to start with the default ControlTemplate and to get that working before you make any changes to it. From there, you should just make small changes and run your project regularly to ensure that your changes are what you wanted. You'll get there in the end.
This question already has answers here:
WPF Get Element(s) under mouse
(3 answers)
Closed 9 years ago.
I'm writing a WPF application, and I've come to a point where I need to get the UI Element that the mouse cursor is over at the time of a keypress. Basically, we have lists on the screen, and if the user enters Ctrl+Shift+F, they will be able to filter the objects just in the list that their mouse is over. I've done some research on this, and the only related questions I've found have to do with moving the cursor to a certain element on a keypress, not finding the element that the cursor is already over. I don't have any code to show for this since it is more of a conceptual question, but if you need any more detail from me, please let me know. Thanks!
var elementundermouse = Mouse.DirectlyOver as FrameworkElement;
This question already has answers here:
Best way to make Windows Forms forms resizable
(2 answers)
Closed 9 years ago.
I work on VS 2010 with C#. Even thought i set window state to maximum some panels of the form are not fit to screen when changing the resolution. How to solve this problem ?
This doesn't happen automatically. In order to get child controls to change their size with the parent form, you have to set some properties. Specifically, look at the Anchor and Dock properties.
Lots of questions about this already here. I can't do better than Simon's explanation.
As #Cody stated, Anchor and Dock can solve a lot of layout needs. For more complicated layouts, however, you may want to look at utilizing the TableLayoutPanel().