Click here to Skip to main content
15,885,914 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Binding custom objects collection to ListBox in WPF?? Pin
Mark Salsbery5-Nov-09 9:42
Mark Salsbery5-Nov-09 9:42 
QuestionNew to WPF - Would this be easy to implement? Pin
AksharRoop4-Nov-09 19:36
AksharRoop4-Nov-09 19:36 
AnswerRe: New to WPF - Would this be easy to implement? Pin
Mark Salsbery5-Nov-09 7:24
Mark Salsbery5-Nov-09 7:24 
QuestionRe: New to WPF - Would this be easy to implement? Pin
AksharRoop5-Nov-09 20:09
AksharRoop5-Nov-09 20:09 
AnswerRe: New to WPF - Would this be easy to implement? Pin
Mark Salsbery6-Nov-09 10:09
Mark Salsbery6-Nov-09 10:09 
GeneralRe: New to WPF - Would this be easy to implement? Pin
AksharRoop8-Nov-09 19:11
AksharRoop8-Nov-09 19:11 
Questionproblem with WPF graph control Pin
ranganaMIT4-Nov-09 17:18
ranganaMIT4-Nov-09 17:18 
AnswerRe: problem with WPF graph control Pin
hb521342144-Nov-09 18:04
hb521342144-Nov-09 18:04 
You can use System.Threading.Timer just like you would in non-WPF code. The problem that you will likely encounter is that DependencyObjects (many object within WPF derive from a DependencyObject) often need to be used within in the object's original thread context. This is easily handled by having your background thread trigger an action within the dependency object's thread. For example to make a TextBlock with a background that alternates between red and blue every 1 second, try the following:

using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
class FlashingText : TextBlock
{
   Timer timer;
   public FlashingText() {
       timer = new Timer(new TimerCallback(Flash), null, 0, 1000);
   }
   void Flash(object state) {
       Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(ToggleColor));
   }
   void ToggleColor() {
       Background = Background == Brushes.Blue ? Brushes.Red : Brushes.Blue;
   }
}


A few notes of caution:

I have not tested the code above, I just scribbled it out to illustrate a concept. It may need a few tweaks to compile.

Also, composing a graph with a large number of elements within WPF will often slow the UI thread and may lead to temporary hanging of the UI. To reduce this problem, there are a number of techniques that can reduce or eliminate this issue. In my experience, drawing more than a few thousand points is likely to provide disappointing UI interaction without an efficient design.
QuestionXAML TEmplate Pin
Saiyed Alam4-Nov-09 16:08
Saiyed Alam4-Nov-09 16:08 
AnswerRe: XAML TEmplate Pin
Richard MacCutchan4-Nov-09 23:20
mveRichard MacCutchan4-Nov-09 23:20 
QuestionHow to find a height of a Grid Row at runtime? Pin
dbrenth4-Nov-09 7:40
dbrenth4-Nov-09 7:40 
AnswerRe: How to find a height of a Grid Row at runtime? Pin
dbrenth4-Nov-09 7:49
dbrenth4-Nov-09 7:49 
GeneralRe: How to find a height of a Grid Row at runtime? Pin
d m patel4-Jan-10 22:24
d m patel4-Jan-10 22:24 
QuestionRe: How to find a height of a Grid Row at runtime? Pin
d m patel4-Jan-10 22:01
d m patel4-Jan-10 22:01 
AnswerRe: How to find a height of a Grid Row at runtime? Pin
dbrenth5-Jan-10 5:26
dbrenth5-Jan-10 5:26 
QuestionHow to animate the ListBoxItems in WPF. Pin
wasimsharp3-Nov-09 17:20
wasimsharp3-Nov-09 17:20 
Questiondrag image Pin
RongNK3-Nov-09 13:31
RongNK3-Nov-09 13:31 
AnswerRe: drag image Pin
Christian Graus3-Nov-09 13:39
protectorChristian Graus3-Nov-09 13:39 
GeneralRe: drag image Pin
RongNK3-Nov-09 15:25
RongNK3-Nov-09 15:25 
GeneralRe: drag image Pin
Christian Graus3-Nov-09 16:29
protectorChristian Graus3-Nov-09 16:29 
GeneralRe: drag image Pin
RongNK3-Nov-09 20:19
RongNK3-Nov-09 20:19 
GeneralRe: drag image Pin
Mark Salsbery4-Nov-09 8:02
Mark Salsbery4-Nov-09 8:02 
GeneralRe: drag image Pin
Christian Graus4-Nov-09 11:37
protectorChristian Graus4-Nov-09 11:37 
GeneralRe: drag image Pin
Mark Salsbery4-Nov-09 11:50
Mark Salsbery4-Nov-09 11:50 
GeneralRe: drag image Pin
RongNK4-Nov-09 16:12
RongNK4-Nov-09 16:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.