This is my first question on stack-overflow so don't kick it))
I have a problem trying to create a Mac-style slider control. I have found this solution and I have implemented it in my solution, but it still doesn't satisfy me cause I need a more universal solution.
Basically I need to create this slider control with the help of four pictures - right, left and center(the rest of) pictures of track bar and one picture for thumb. These are PNG files.
Could I style default WPF slider to support such resource-oriented behavior?
I'm really astonished that all samples includes templates for style but no one supports something like
<TrackBarLeft>
<Image for left>
</TrackBarLeft>
....
Could any one give me a solution for this problem?
Thank you very much
Sams "WPF Control Development Unleashed" has some guidelines on this. Check out Chapter 5: Using Existing Controls - it has an example based on a scrollbar - it might be useful.
Related
I am new to C# WPF and working on somebody else's code.
(WPF version 3.0.6920.5011, as read from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Presentation Foundation)
I already gave a look to various (quite old) Stackoverflow solutions, but they don't seem related to this problem: WPF Blurry fonts issue- Solutions, Text is blurred when transformed in WPF.
WPF: Why does text and elements blur if I use dropshadow effect on a parent item looks interesting, but there are no shadows applied to parents.
I observe this "blur" effect whenever an element is included in another one, and it is more and more visible as the inclusion goes deeper:
Device tab's text is perfectly readable
Global, Common and Inputs tabs' texts are lightly blurred
Pane inside Inputs is highly blurred.
Alas I cannot provide XAML files because of company rules, but there are no settings about ClearType, applied shadows nor to blur effects.
Is there anything else I could check?
Thank you in advance
Add this to your top-level <Window> tag:
TextOptions.TextFormattingMode="Display"
This was first announced 10 years ago in a Microsoft post, it's amazing how to this day so few people use it.
I am currently learning WPF framework; I have some past (not much though) experience with Winforms. One problem I've had in both is that the menubar does not look native. I've found a workaround in Winforms, but I haven't been able to find anything for WPF. I've not had this problem in other frameworks I've used, particularly Qt.
In many pics I've seen, it looks native enough in Windows 7, but not Windows 10. I included some pics.
How it currently looks:
How it should look:
Thanks in advance!
Edit
While I have not seen the possible duplicate link, I am aware of setting the foreground/background on WPF controls. That link doesn't really answer my question. I don't want to come up with my own style at this point; all I want to do is make controls look native.
If custom styling is the only way, that's fine, but if there is another way, that would be preferable.
Thanks!
I don't think there's a quick fix to get what you want. WPF renders using DirectX, allowing for much more flexibility in styling applications. A WPF app should render exactly the same way on any version of Windows - it will not automatically adopt a native look and feel (that was actually one of the main selling points of the technology in its early days).
While MS made the default styling somewhat close to Windows at the time of release (Vista, I think?), if you want WPF controls to have a particular look you're going to have to style them yourself.
I've decided to learn a bit of WPF and I've created an application with the Mahapps Metro library and it interacts with a SQLite database (Unrelated but a bit of background).
I'd like to draw an object, let's say a triangle, in a new window.
I've seen this - Click - but the drawing of the shape needs to be visible to the user. So the user will see the line being drawn from point A to B to C to A. The image will "reload" after a few seconds i.e. Clearing the window/canvas and redrawing the triangle.
Are they any libraries out there that might make this easier or does WPF have something else I can use to achieve this?
Also, the redrawing of the triangle will be in a separate thread running a loop. Something tells me this isn't going to be very efficient. Is there a better way initiate a "redraw"?
My "answer" are some helpful searches and a few results that might help you get to the next step of deciding on a design that works for you.
Yes, WPF does have facilities to help you achieve some animation in drawing lines.
I searched for "wpf animate line drawing" and some interesting links for your research are:
How do you animate a line on a canvas in C#?
generating animated line
Drawing line "slowly" programmatically with wpf
Hopefully this gets you going in a good direction. Best of luck with your project.
I am a Silverlight developer and in Silverlight we made use of PlanarProjection to create such effects. Infact this is the article along with demo project in Silverlight by Mike Taulty:
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/04/27/silverlight-3-simple-flip-control-built-on-planeprojection.aspx
How can we make such a realistic control in WPF because there is no PlanarProjection (2.5D) in WPF4. Can you provide me any code or guideline or sample project along with source code?
WPF lacks the PlaneProjection of Silverlight. It's annoying that these incompatibilities exist, but admittedly the problem is usually Silverlight lacking a WPF feature. So this time for WPF developers the shoe is on the other foot!
If what you want is PlaneProjection, here is an article that implements a feature with similar capabilities:
PlaneProjection in WPF (previously, link is now dead)
which itself also references some other attempts.
But if what you want is a WPF dual-sided content control with flipping similar to the article you linked, you can use Josh Smith's ContentControl3D:
Introducing ContentControl3D
Rotating WPF Content in 3D Space (The Code Project)
This control can flip front and back content in a very configurable way. I wouldn't be surprised if Mike Taulty's implementation was inspired by it.
Someday WPF may have PlaneProjection and then the same technique will work for both Silverlight and WPF. Until then, you can easily adapt the simple PlaneProjection flipper to use the same API as ContentControl3D as a compromise.
So here's the situation: I need to take a (user-specified) graphic, and allow the user to define and label regions within that graphic. For example, if you uploaded a picture of a face, you might want to define "right eye", "left eye", "nose" etc. Also, having defined the regions, if I select a previously defined region, it should be highlighted on the image somehow. These regions are (obviously) not necessarily rectangular, and they cannot overlap. And if you click within a defined region in the graphic, I would be able to identify which region was clicked on.
There are a couple ways I can think of for doing this, none of which are quite satisfactory. Another developer before me tried doing it with a transparent grid overlaid on the original graphic, fiddling with the background alpha/color for highlighting regions, but I think they rather kludged it. I could either get my hands really dirty trying to clean up their code, or try a completely new approach.
What would you suggest for maximum speed and user-friendliness?
Bounty added: for the best solution that will get me up and running in the minimum time.
The GraphicsPath class is made to do this. Keep a list of them along with the image. Draw the image first, then Graphics.DrawPath() to draw the regions on top of the image.
Hit testing is simple with GraphicsPath.IsVisible(). Iterate the list in reverse order so overlaps work.
Assuming you haven't decided yet on the technology you'll use, I'd suggest WPF; I find most graphics-related tasks easier with WPF (at least in version 4) and it's specifically geared for interactivity, so creating non-rectangular regions using mouse clicks and hit-testing clicks to select shapes would be pretty easy. Loading images is also easy.
However, if you haven't used WPF or Silverlight until now, there is some overhead in learning the basic concepts and APIs; so I'm afraid there's no real way I can recommend it as a maximum speed solution without knowing your (or whoever's will be working on it) competencies. That said, using MVVM and WPF would be definitely the maximum speed solution for me. Also the maximum user-friendliness since WPF enables quite interesting interaction models out-of-the-box, like multi-touch support (that's the trendy one that should be mentioned, right?) and easy non-standard layout and placement of controls.
You need polygons, saved as list of points. And you need hit testing for them. See the link:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/40ebadc1-6154-4c7c-9cb1-d608a426b29c