I have a Grid with 2 rows, where the second has Visibility.Collapsed by default.
I want it to change to Visibility.Visible on MouseEnter on the Grid and back on MouseLeave.
That's simple and done.
However, I would like the transition between Visible and Collapsed to not be instant but smooth.
I believe I can do this somehow with the VisualStateManager but I'm not sure how, so any guidance is appreciated.
You're looking for an animation. The easiest way to see how these work is to set one up in Microsoft's Expression Blend. Look at the resulting code and see what they did (it can be somewhat long, so only include the bare number of elements needed in your test stup).
Most likely, you'll end up using something other than just the Visibility property, since animations require numbers and the Visibility property has only discrete values. Animating both the Opacity and Height properties sounds about right.
another approach is to use transition control
http://www.silverlight.net/archives/videos/silverlight-toolkit-animatedtransition-control
This is probably the quickest way without having to build anything custom in blend.
Related
I need a control where user can pick only one option. Combobox is fine, radiobuttons are ok, but for some purpose I think about another crazy, but interesting solution.
There should be a slider control on a window and three possible positions of this sliding thing. I know this can be easily accomplished by setting slider's Minimum and Maximum plus TickFrequency and IsSnapToTickEnabled properties.
Now, is there a way how to add labels on left/right edge and center of slider showing user options within the slider? Or is it neccessary place labels/textblock below?
Last, though the most important thing is, how to associate integer slider positions with string options? I thought about switch, but this is wpf - there is "more wpf" solution, isn't it?
Just drag slider's rider to it's position and by binding set class string property to appropriate value.
Every control within WPF can have its visuals completely modified to suit your needs. This was/is the beauty of WPF over WinForms.
Can your slider have a TextBlock within it? Absolutely. Style as you desire and be on your way. A great article can be found via MSDN Magazine which outlines the approach to customizing WPF controls.
With regard to the integer values, use an IVauleConverter to translate the values to whatever you prefer.
I was wondering the need for custom xaml code for buttons.
Using images like in html should be faster.
Yours thoughts please.
The whole point of WPF is that it is independent of pixel resolution or DPI. If you use raster images for the buttons it is no longer DPI independent and can look bad on some resolutions. If, instead, you use WPF objects and geometries, those will look almost exactly the same on any DPI.
What happens when you want to change something small to do with the button? Using custom XAML allows me to apply the same template to all my buttons, and change them all by just changing that template. It also means that I can tweak small things without the need to constantly regenerate those images.
As for speed, you're best off not pre-empting the framework's optimisations until you actually encounter a performance issue.
EDIT: I should also note that the Image class doesn't inherit from Button, and as such you can't do the direct binding to an ICommand property in the ViewModel.
I am using a third party charting library (Infragistics xamChart). I am not satisfied with how tooltips are displayed on a line charts datapoints so I was thinking of using an adorner to make a better looking/interactive tooltip.
What I want to do is have the adorner popup whenever one of the datapoints is hovered over. Does anyone have any pointers on how I can do this? Most of the adorner samples I found are pretty simple ones that just alter the entire control they are adorning.
My main questions are:
Is it possible for an adorner to
appear only when certain elements are
hovered over (and have it appear at
the current cursor position)?
Does anyone have a simple sample they
can share?
Are adorners the right way to go
here? I think the only other option
was to use the popup control but I
though adorners were a nicer
solution.
Thank you.
Perhaps Attached Behaviours could help you? From this article:
The idea is that you set an attached
property on an element so that you can
gain access to the element from the
class that exposes the attached
property. Once that class has access
to the element, it can hook events on
it.
That way you could attach a listener to the MouseEnter event and display your custom ToolTip from there.
Hi
I am trying to render buttons as the item template of a list, to be displayed horizontally. The problem is that they don't 'butt up' to each other. They leave a small gap betwen each one. I have tried allsorts of things to cure it, but have'nt succeeded.
Any ideas?
Try using the WPF tool Snoop to work out where the margin is coming from, and then fix it.
(Negative margins = code smell, in general, IMO.)
Try a negative margin, setting cliptobounds to false, maybe that can help
It's most likely either a Border, Margin, or Padding on your item container (i.e. ListBoxItem if you're using ListBox) which can be corrected with the ItemContainerStyle or your Button's Border is using BorderThickness=1, BorderBrush=Transparent or null.
Use Snoop as Dan suggested to find out.
How to draw border around text inside richtextbox control?
Not sure your question is quick specific enough, could you post a mockup of what you want?
...However... typically you'll go about doing somehting like this by overriding the OnPaint() method of the RichTextBox. There you can access the Graphics object being used and grab whatever Brush makes sense.
Also, in overriding OnPaint, make sure to call base.OnPaint(e) prior to performing any of your custom work--without this nothing will show, and doing it after your custom work might undo your work.