|
Hi,
I have a WPF textbox and I want to validate the text the user types i.e. only numbers are allowed. To do this I have set
<pre>Text="{Binding MobileNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}</pre>
And the property is
<pre> public string MobileNumber {
get {
return mobileNumber;
}
set
{
if (AllowedPhoneNumberCharacter(value))
mobileNumber = value;
OnPropertyChanged("MobileNumber");
}
}</pre>
If the user types a character we came to <i>set </i> and after OnPropertyChanged("MobileNumber"); a call to <i>get </i>is made. But the textbox is not updated, why?
Example:
09876 :User types o phone number. OK
098767 :User adda a digit 7. OK
098767g :Not OK to add g. Now I want to update textbox with 098767.
Regards
Marc
|
|
|
|
|
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.
My 2 cents,
Richard
|
|
|
|
|
Dear friends
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
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
This question is really outside the scope of Silverlight.
Silverlight runs via a plugin hosted on a web page in a browser.
You need to know how to publish that web page.
That means you need an HTTP (web) server, like IIS, Apache, etc.
You should really ask on the web development board.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Then how we access silverlight application from different system or Computer?
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
Piyush Vardhan Singh wrote: how we access silverlight application from different system or Computer?
The same way you access any web site.
Really, what you need to know is how to publish a website - it
will make sense when you know that.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
My Dear Friend
Thanks for continue reply....
supposed that my silver light application Url :-
URL:-http://localhost:2328/FileConversionTestPage.aspx
its work perfectly on my machine.it did not access through IP from different Machine and my machine.
URL:-http://192.168.12.5:2328/FileConversionTestPage.aspx
I also Create virtual Directory it also work Url:-
http://localhost/FileConversion/FileConversion.Web/FileConversionTestPage.html
http://192.168.12.5/FileConversion/FileConversion.Web/FileConversionTestPage.html
from my computer main page is open but when web services connection is going to connect then its give the Error:-
System.reflection.targetInvocationException:....... remote server returned an error:Not Found
it also did not access from different machine URL;-
http://192.168.12.5/FileConversion/FileConversion.Web/FileConversionTestPage.html
So I Want access my this Url:-
http://localhost:2328/FileConversionTestPage.aspx
From different machine. Please Help me to resolve my problem.
Thanks
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
Piyush Vardhan Singh wrote: So I Want access my this Url:-
http://localhost:2328/FileConversionTestPage.aspx
From different machine. Please Help me to resolve my problem.
You need to figure out what the actual URL is for the web server you're hosting
on.
Again, this has nothing to do with Silverlight and you really should be asking on
a web development board.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i want know only one thing how to host silverlight project from my local host for every body in company.
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
Eventure Technology
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
|
Hi,I want curve in all corners of textbox in wpf..
I got this by following code in dynamic resource.
But from that i can't input anything in textbox.
Any Suggessions?
<Style x:Key="UserNameTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border Name="Border" Background="#FFEBE9E9" BorderBrush="#FF8B8787" BorderThickness="1" CornerRadius="3" Padding="3"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
|
|
|
|
|
This should work,
<Style x:Key="UserNameTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border Name="Border" Background="#FFEBE9E9" BorderBrush="#FF8B8787" BorderThickness="1" CornerRadius="3" Padding="3">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
|
|
|
|
|
Thanks a lot..
Can you please explain shortly about,
<ScrollViewer x:Name="PART_ContentHost"/>
|
|
|
|
|
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.
From here, MSDN[^]
|
|
|
|
|
Windows 7 has this wonderful Thmbnail view of open windows when you hover over icons on the taskbar > http://windows7news.com/windows-7-screenshots/?album=1&gallery=13&pid=287
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.
Christian Graus
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 )
|
|
|
|
|
Hi Christian,
Thanks for the feedback. Eslam Afifi seems to have an idea worth fleshing out...
|
|
|
|
|
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.
Eslam Afifi
|
|
|
|
|
Hi Eslam,
The RenderTargetBitmap.Render sounds interesting. Will have a play with it tonight and see if it does what's required...
Not sure how to 'bind the thumbnails viewer to the windows'; convert I have no issue with.
Will post my findings...
modified on Wednesday, April 8, 2009 4:43 PM
|
|
|
|
|
Hi Eslam,
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) _
Handles Button1.Click
Dim CaptureForm As New TestForm
CaptureForm.Left = -999
CaptureForm.Show()
Image1.Source = CaptureFrameworkElement(CaptureForm)
CaptureForm.Close()
CaptureForm = Nothing
End Sub
Function CaptureFrameworkElement(ByVal fe As FrameworkElement) As BitmapSource
Dim renderBitmap As New RenderTargetBitmap(CInt(Math.Ceiling(fe.ActualWidth)), _
CInt(Math.Ceiling(fe.ActualHeight)), _
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),_
VisualTreeHelper.GetDescendantBounds(fe).Size)
dc.DrawRectangle(visualBrush, Nothing, rect1)
End Using
renderBitmap.Render(dv)
Return CType(renderBitmap, BitmapSource)
End Function
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.
Any thoughts?
|
|
|
|
|
GraGra_33 wrote: 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(), _
IntPtr.Zero, _
Int32Rect.Empty, _
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions())
Eslam Afifi
modified on Wednesday, April 8, 2009 2:31 PM
|
|
|
|
|
Thanks Eslam,
I was hoping for a more WPF native solution rather than a hack... Will try tonight...
|
|
|
|
|
You're welcome.
So, how did it go? Did it work? Could you find any WPF method? I'm also wondering, why would you want to show non-client area in the thumbnails?
Eslam Afifi
|
|
|
|
|
I couldn't get around your problem... So I tried something different but not getting an image...
Dim hlper As New System.Windows.Interop.WindowInteropHelper(Me)
Dim gr As System.Drawing.Graphics = System.Drawing.Graphics.FromHwnd(hlper.Handle)
Dim ms As New MemoryStream
Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(gr.VisibleClipBounds.Width, gr.VisibleClipBounds.Height, gr)
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim bImg As System.Windows.Media.Imaging.BitmapImage = New System.Windows.Media.Imaging.BitmapImage()
bImg.BeginInit()
bImg.StreamSource = New MemoryStream(ms.ToArray())
bImg.EndInit()
Return bImg
Any thoughts?
PS: I'm running in fullscreen mode and want preview and open window thumbnails as navigational tools...
|
|
|
|
|
This won't work.
GraGra_33 wrote: Dim gr As System.Drawing.Graphics = System.Drawing.Graphics.FromHwnd(hlper.Handle)
A Graphics object is just a drawer.
GraGra_33 wrote: Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(gr.VisibleClipBounds.Width, gr.VisibleClipBounds.Height, gr)
It takes only the resolution from the Graphics object.
I can't think of any other ideas. I see no reason why you would want to draw the non-client area! Maybe you should rethink why you would need the non-client area.
Eslam Afifi
|
|
|
|