How do I go about adding a 'Command' property to a custom WPF control derived from an existing control? I want to use the Command property the same way you would use a Command property on a button--to bind to any ICommand or routed command.
I rely heavily on MVVM, and my UI controls are almost always bound to ICommand objects in my view model. I have started using the Actipro Wizard control for my WPF wizards, and it's very good. But it's missing one thing: It won't let you bind a command to the activation of a wizard page.
In many wizards, a process should start automatically when a wizard page is activated. For example, in a file copy wizard, pages 1 and 2 get file paths from the user, and when the user advances to page 3, the copy should begin automatically, displaying a progress bar for the operation.
Unfortunately, the Actipro WizardPage doesn't have a Command property that fires a command when the page is activated. It does have a 'Selected' event, which I'm using now. But I would rather bind to a command in XAML, so I am extending the ActiPro WizardPage control to add a 'Command' property that will fire when the page is activated.
Can anyone point me to any articles or blogs on how to implement a 'Command' property and give the derived control the CanExecute() behavior expected of a command-bound control? Thanks.
Found my answer. A derived control that wants to implement a Command property must implement the ICommandSource interface. There is an MSDN article[^] that shows how to do it, as well as a code sample[^].
I believe the PropertyChanged is not fired until the user leaves the textbox. I believe you have to process the KeyDown events to get that kind of control. You can check to see if the key is an alpha character. If the key is an alpha then set the e.Handled property to true and the keystroke won't go the text area.
any body help me to host silverlight project from local host(Step by Step Processors).
I have got lots of link but that are not help full . that very confusing in virtual directory and MIME Type. that link are not sufficient to understand of deployment of Silver Light Project please help me
The ControlTemplate for a TextBox must contain exactly one element that is tagged as the content host element; this element will be used to render the contents of the TextBox. To tag an element as the content host, assign it the special name PART_ContentHost. The content host element must be either a ScrollViewer or an AdornerDecorator. The content host element may not host any child elements.
I'm trying to add the same functionality to a WPF application that allows the user to see thumbnails of static and dynamic forms when not loaded but also thumbnails of forms that are open and loaded with data.
Anyone have any ideas on achieving this functionality?
In Winforms there's a method on the form you can use to tell it to draw itself to a bitmap. Not sure if WPF has the same thing. If a form is 'not loaded', then it does not exist, you'd need to store default thumbnails to show in that instance.
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
A similar method to the one Christian mentioned is RenderTargetBitmap.Render[^]. It doesn't work exactly the same way the Control.DrawToBitmap[^] does. I tried to draw in the constructor after initialize components while the window is minimized and they gave different results.
Also, try to bind the thumbnails viewer to the windows and use a converter to convert a window to an image. But I'm not sure if this would work specially when a window is hidden or minimized.
Thanks for the pointers ... What I've come up with is the following:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.Windows.RoutedEventArgs) _
Dim CaptureForm As New TestForm
CaptureForm.Left = -999
Image1.Source = CaptureFrameworkElement(CaptureForm)
CaptureForm = Nothing
Function CaptureFrameworkElement(ByVal fe As FrameworkElement) As BitmapSource
Dim renderBitmap As New RenderTargetBitmap(CInt(Math.Ceiling(fe.ActualWidth)), _
96, 96, PixelFormats.Pbgra32)
Dim dv As New DrawingVisual()
Using dc As DrawingContext = CType(dv.RenderOpen(), DrawingContext)
Dim visualBrush As New VisualBrush(fe)
Dim rect1 As New Rect(New System.Windows.Point(0, 0),_
dc.DrawRectangle(visualBrush, Nothing, rect1)
Return CType(renderBitmap, BitmapSource)
This will let you capture any visual element. The only issue I have now is that only the contents of the form are captured and not the non-client area.
The only issue I have now is that only the contents of the form are captured and not the non-client area.
I'm thinking about accessing the Window as a Form, and call the DrawToBitmap. But I couldn't get it to work now and I don't know if it's possible. I have an exam tomorrow so I can't investigate it further right now. Maybe if there is some Win32 API that does take a snapshot of a window by handle, since we can access the handle.
' the code is not tested
Dim hlper As New System.Windows.Interop.WindowInteropHelper(Me)
Dim windowAsForm = System.Windows.Forms.Form.FromHandle(hlper.Handle) ' returns null, don't know why
Dim w = windowAsForm.Size.Width
Dim h = windowAsForm.Size.Height
Dim bitmap As New System.Drawing.Bitmap(w, h)
windowAsForm.DrawToBitmap(bitmap, New System.Drawing.Rectangle(0, 0, w, h))
' code from <a href="http://dedjo.blogspot.com/2007/05/how-to-use-systemdrawingbitmap-hbitmap.html">here</a>[<a href="http://dedjo.blogspot.com/2007/05/how-to-use-systemdrawingbitmap-hbitmap.html" target="_blank" title="New Window">^</a>], i didn't test it
Return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), _
modified on Wednesday, April 8, 2009 2:31 PM
Last Visit: 31-Dec-99 18:00 Last Update: 25-Jun-22 12:47