I need to customize the appearance of the slider in order to use it in touchscreen mode. The slider's thumb needs to be 60 - 80 px high.
From all the suggestions around I understand that I will have to modify the slider's control template.
What I was wondering: where can I get the slider's control template? I want the slider to look the same as it does originally, just with a bigger thumb.
In Expression blend you can edit a copy of the original template , it's a good place to start for all control template modifications.
or you can search for the original template on the web :
Slider Tempalte and Style
You don't need Blend to edit a Template.
Right click your slider in VS Designer Edit Template -> Edit a copy..., go ahead and play with it. If you're familiar with XAML it should not take too long for you to get it right.
Just remember that WPF/WP is all about DPI independence. If you fix a Height and Width at a certain value, in some screens the control may look small/large!
Related
I have wpf project with one Window (MainWindow). Depending upon the config file it shows one of two UserControl's as Content. It may be a horizontal (1920x1080) control or vertical (1080x1920) control. It's fine with horizontal screen, but when vertical is loaded I would like to do:
1) rotate window/control by 270 degrees
2) change primary screen orientation
I would prefer to just rotate application and don't interact with windows API. I can't change orientation manually, because I have only remote access to this computer.
You can not rotate the Window object itself, as it is positioned by the window management system built in Windows. You can, however, transform (and thus rotate) any FrameworkElement inside the window. This includes, but is not limited to, the Grid, the Button and the TextBox elements.
All you need to do is edit the LayoutTransform property on the element you want to rotate, which is most likely the root element in your window. Set the rotation to 270/-90 degrees and WPF will automatically rotate your UI.
Because you are using the LayoutTransform property, the layout system will also scale you UI correctly. The RenderTransform property causes the control to first be rendered, then be rotated.
YES WE CAN CHANGE SCCREEN ORIENTATION USING
DEVMODE & using System.Runtime.InteropServices;
its bit late to reply but I am replaying for the new ones , if someone com across this article for change screen rotation in C# or VB .
Please use the link given below to get help Mr. Hannes Completely write an article to change screen rotation and luckily its working fine for me (Windows 11) as now of..
https://www.codeguru.com/dotnet/creating-a-screen-rotator-in-net/
How would you guys go about creating a slider where the thumb stays centered, but the image or background of the slider slides with a slide gesture.
The only real example I could find is here, in the second screenshot:
http://www.windowsphone.com/en-US/apps/5ffe35e4-8e43-e011-854c-00237de2db9e
Basically the slider "thumb" would stay in place, but the numbers on the scale move with a finger swipe.
Just looking for some direction here on how you would approach this. What control would you recommend I start with? Or would it be easier to create a custom control?
I haven't tried it but a slider might be too hard because of the way it is constructed; the area/scale that you want to slide consists of two repeat buttons and those do not easily slide. So it might be best to NOT use the slider because the code of the Slider class expects these template parts to be present.
I'd try with plain, templated control. The thumb is pure decoration. I'd add the 'scale' in a scrollview without scrollbars.
What's the correct pattern to resize controls when a font size changes?
For example, I used the WPF designer to make a form, and placed UI elements from the toolbox. Late in the game I got the requirement that the font size of every UI element needs to be configurable, so now I'm thinking there has to be a better way to resize controls when the font size changes. Right now I'm doing alot of code behind calculations on Margin properties.
For such cases I usually place my control inside Grids and StackPanels, this way font size won't affect the layout, everything will be stretchable.
Never place controls on the Window using absolute coordinates.
Make sure your Height and Width on the controls are set to Auto.
When you use the designer/toolbox to add controls it usually provides a static height/width. If you type the tag in the XAML editor you get the control default which is usually Auto.
You'll notice the black diamond in the property window next to the attributes that are changed from their default value. You can right click and choose reset value to clear the attribute from your XAML and see what the default value is.
My aim is to get fine control "animation" when it is mouse-over-ed. For example, I have a "map" of controls (game map that represent different type of terrain), each of them is an image with trees/rocks/hills on the green grass or water (lake or see) image of blue/cyan color. When user point any image with mouse it should get shiny: either get more bright background or get a shiny border.
It is hard to say what exactly I want to have (either background change or border), I would like to try each of them and see what is the most appropriate for me.
I am going to have a custom control (MapTile) that will represent a map tile. I know how to catch MouseEnter/MouseLeave events, but not sure how to change control style and if it is a good idea to work with control style in CodeBehind, probably there are better XAML-based solutions.
Could you please help with a solution that provide few goals:
Goal1: Add highlighted border around the control (it will be squares/rectangles, or circles; use what is easier) on mouse enter, remove border on move leave;
Goal2: Change some properties of my CustomControl (for example, background color).
Thank you very much!
1. How to han
You might find it easiest to get hold of Expression Blend and use it to create a custom template for your control.
The Learn Expression Blend page would be a good place to start. Look for tutorials on customising buttons and this is the same sort of thing that you want to do.
You need to use an attached behavior on your control. You don't need to learn Blend for this.
Check this one as an example, but you can search the site for Mouse Over for other examples.
http://gallery.expression.microsoft.com/en-us/MouseOver3D
I would like to create a scrollbar in WPF that looks like the one seen in iTunes cover flow. See scrollbar image below, which also shows the reflection of the album art underneath the scrollbar.
Scrollbar Image http://www.barramsoft.com/pub/images/scrollbar2.jpg
Below is a basic scrollbar control in xaml.
<ScrollBar Name="scrollBar1" Height="24" Width="Auto" Orientation="Horizontal"
SmallChange="1" />
How can I get from the above to an iTunes cover flow scroll bar look? The full ready to use source code sample would be preferred.
Start with the ScrollBar ControlTemplate Example in MSDN from http://msdn.microsoft.com/en-us/library/ms742173.aspx (that is much easier to modify than the window style you can get from Blend or ShowMeTheTemplate)
Now start to edit the template, change the colors, the templates for the arrow buttons and the thumb until it looks like you want.
Have you got Expression Blend? If not I'd recommend installing it (there is a 30 day trial version if you don't have an MSDN license).
There are quite a few Expression Blend tutorials out there here's a good place to start for example.
Basically you copy the template for the standard scroll bar which will give you all the elements that go to make it up. You then change what each element looks like until you get it looking how you want it. There will be a fairly large amount of trial and error in this process.
The first task is to show the scrolled area underneath the scrollbar. You have to change the structure of the ScrollViewer control. By default it is a 2x2 Grid so the horizontal scrollbar is under the scrolled area. Edit its template to put the scrolled area and the scrollbar in the same cell, vertically aligning the scrollbar to bottom.
The second part is to style the scrollbar itself. I don't believe this can't be done with rounded rectangles.
I usually extract the template to modify it using Blend, there is also a free ShowMeTheTemplate tool.
Have a look at the WPF Themes project at codeplex. The Expression Blend Theme (light/dark) is very close to the example you've provided. It is released under Ms PL.