Help Single UIElement Refresh

kimosavi

Active member
Joined
Apr 9, 2009
Messages
34
Location
Chicago, IL
Programming Experience
3-5
Hi,

I tried different way to update the UI in WPF and I happy with the following Code:


VB.NET:
            Shared Sub Refresh(ByVal sElement As UIElement)
                sElement.Dispatcher.Invoke(New Action(AddressOf DoEventsHandler), DispatcherPriority.Background)
            End Sub

            Private Shared Sub DoEventsHandler()
            End Sub

USESAGE:
Refresh(Wrappanel)

The problem with this is that it will not refresh ONE SINGLE object but the whole Window/Page.

I need to refresh ONE UIElement (like a Wrappanel or a TextBox) without affecting the render of the other objects.

Any Ideas??
 
Thanks jmcihinney,

I did some research myself and looks like all the code I found so far is to refresh the whole UI and not just one object...

found this interesting article
WPF Threads: Build More Responsive Apps With The Dispatcher

and this too... most of them i C# but can't seem to make it work in VB
Refresh the GUI in a WPF application
WPF UI Update from Background Threads - <ChristophDotNet
wpf - Is there a better way to update UI Element with Dispatcher? - Stack Overflow

Most explain that the trick is using the BeginInvoke instead of Invoke of the dispatcher... but still it does not work.

Any Ideas?
 
Back
Top