How I can make a custom vertical slider in C#? [duplicate] - c#

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.

Related

Is there a way to allow default control painting, while adding my own painting? [duplicate]

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.

designing "pretty" user controls [duplicate]

This question already has answers here:
Creating a WPF Custom Control
(2 answers)
Closed 7 years ago.
I would like to create a user control which represents a pie chart and offers some mouse-over (tooltips / highlighting) and on-click events for the different parts of the chart.
However since i can not see how this could be accomplished by combining and restyling any of the standard controls the only thing i can think of is drawing the parts of the chart one-by-one using System.Windows.Shapes and to try to generate a pie chart by piecing those together.
Since "drawing" my buttons on the UI doesn't seem right, i would like to know if there is some other way to get such a result. Ideally the proposed solution allows me to apply styles to the chart so that it doesn't look flat, but can be adapted to the look of other controls.
In order to fulfil your requirements, you will need to create a CustomControl. You can find a basic tutorial in the How to Create a WPF Custom Control page on WPF Tutorial.net, but you will need to do more than shown there.
You can find a better tutorial in the WPF Control Development Unleashed book and luckily for you, someone uploaded a PDF version of it here... take a look at chapter 3.
Have a look at this site. It explains how to draw arcs and manage custom shapes.

Using animation in Picturebox [duplicate]

This question already has answers here:
Can a PictureBox show animated GIF in Windows Application?
(3 answers)
Closed 9 years ago.
Im working in 2D space invaders game and i have done all the important part. Then, I decided to add some animation in the pictureBox to make my game look much better. My idea is to make the background picture as stars and i want to move this stars so it appears that my spaceship is actually moving.In different words, i want to make the background picture moving and repeat it again and again.
i feel there is easy way to make, can help me please with key points to overcome this issue.
thanks in advance
I think this has sort of been answered already in how to use an animated gif for a PictureBox, in this case you'd have your stars moving as part of a gif.
Link to Answer
Although I wouldn't be surprised if it's a better approach to use some other control altogether rather than a PictureBox, but if that's what you're looking to use then hopefully my answer leads you to a solution.

how to detect VerticalOffset's changes? [duplicate]

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;

How to fit Windows Form to any screen resolution in c#? [duplicate]

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().

Categories