silverlight 3: How to create a resizable childwindow? - silverlight

Is there any way to create a resizable childwindow in silverlight 3? Any pointers are highly appreciated.

I don't have any actual code for you, but you would probably want to subclass ChildWindow and handle the MouseLeftButtonDown, MouseMove, and MouseLeftButtonUp mouse events within a certain "border" of the edge of the ChildWindow or within a certain "grip" region (such as the lower-right corner).
You would want to use some standard drag and drop logic to detect that a drag is being performed for a resize and update this.Width and this.Height based on the relative mouse coordinates using the GetPosition() method of the MouseEventArgs class.
You might also want to have a look at the FloatableWindow control on CodePlex, which is a refactored version of the ChildWindow which supports drag and drop moving and resizing.

Take a look at Tim Huer's FloatableWindow. I think this might do what you are looking for.
http://timheuer.com/blog/archive/2009/07/08/silverlight-floatablewindow-updated-with-resizing-capabilities.aspx

Related

How to expand treeviewitem while performing drag and drop operation

When performing dragging over TreeView I want items to expand automatically when mouse cursor is over them for some time (eg. 2 seconds). What would be the approach to solve this problem?
Ideally I'd like to have a custom attached behavior implementation of this problem, something like for scrolling while dragging: http://weblogs.asp.net/akjoshi/archive/2012/05/28/Attached-behavior-for-auto-scrolling-containers-while-doing-drag-amp-drop.aspx
In addition, I'd like to handle any other expandable (eg. Expander) or content-selectable (eg. TabControl) elements in a same manner, but I am not sure if all this can be handled generically (eg. with one attached behavior) or do I need to handle all of them separately?
See my blog article entitled Xaml: Adding Visibility Behaviors Using Blend to A DataGrid for WPF or Silverlight where it demonstrated a mouse over trigger. From that you can apply the behaviors you need using Blend to do the dirty work of adding the triggers.

wpf user control to display on top of current view

I wish to have a user control in my application. The behavior should be similar to a tooltip. That means, when I move the mouse inside my view, this user control also moves.
How to achieve this.
I do not wish to have draggable canvas, just that the top and left of the control change. Actually what i wish to achieve is quite similar to a magnifier. But instead of displaying a digital zoom image I wish to display a cropped image inside the magnify viewer.
You can also use the Adorner class. Hope this solves your problem.
Adorner Class Description (MSDN)

Change number of lines mouse wheel scrolls in WPF ListBox

In a WPF listbox, rotating mouse wheel will scroll list by the number of lines specified in Windows Control Panel, in Mouse Wheel options.
How can I change this, for example I want to scroll WPF ListBox, one line anytime, using mouse wheel.
Thank you.
As you stated it is a control panel setting and you are trying to override it. That will confuse the user. I recommend you to not do that.
However you could try and override various events and position the vertical scrolling by using scrollViewer.ScrollToVerticalOffset(...);
As stated by ygoe in a comment, what you are looking for is :
ScrollViewer.CanContentScroll="False"
In my tests, it does scroll the list one line at a time.
Of course, you should consider that it overrides a global windows setting, as stated by Erno

creating a view within a custom control to hide parts

I'm creating a custom Silverlight control for Silverlight (specifically wp7). My control is mostly a button ,and when someone taps the button , I want to animate a tall rectangle filled with other contents that flys out from behind the button.
The issue is I do not know how to hide or only draw parts of this rectangle as I comes out. For example, when this rectangle is half way out,only the top half is showing while the rest is hidden. How can I do this without having to write some complex code? Presumably I just need to be able to define some sort of 'view' where only things inside this view are rendered to the screen.
Thoughts? Any help is appreciated!
You can use VisualStateManager to define possible visual states for your view. In addition, you can define transitions between those states (incuding animations). In your button's Click event handler you'd need to tell the VisualStateManager to transit to a different state - and you're done.
http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager.gotostate%28v=vs.95%29.aspx
This would probably look like this in your view's code behind :
void OnClick(object sender, RoutedEventArgs e)
{
VisualStateManager.GoToState(this, "StateName", true);
}
In order to easily define the animations, you can use Expression Blend 4
In order to ensure that only the parts of the animating rectangle that are within the parent container are shown and nothing outside of that, you need to be able to clip the parent's children to it's bounds. Unfortunately, there is no ClipToBounds property in Silverlight, but you can use Colin Eberhardt's clipping attached behavior to achieve the same effect.

Resizing controls on a canvas

I have a Silverlight (v3) application that users can drag controls (e.g. Shapes, Images) onto, change the fill colour, drag around etc
I am looking for the best method to allow the user to click on a control, give a visible indication that the control can be reiszed (e.g. display resize handles) and then handle the resizing.
I have played with a few ways of doing this but I am not sure of the best way to make this as clean/generic as possible - ideally I would like to mark a control as resizable and then have common code implement this. I have tried 1) adding a ControlTemplate to a control and 2) handling the MouseLeftButtonDown event and adding a new rectangle which surrounds the object and then resizing the original control as this rectangle is resized.
Does anyone have experience of implementing this, some good code resources?
Have a look at this Resize Behavior

Resources