Click here to Skip to main content
15,867,851 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF Datagrid linked to URL Pin
abollmeyer14-Sep-12 21:42
abollmeyer14-Sep-12 21:42 
QuestionUN Register Scriptable Object Pin
Marc Vandeputte13-Sep-12 7:07
Marc Vandeputte13-Sep-12 7:07 
AnswerRe: UN Register Scriptable Object Pin
Clifford Nelson13-Sep-12 8:34
Clifford Nelson13-Sep-12 8:34 
GeneralRe: UN Register Scriptable Object Pin
Marc Vandeputte13-Sep-12 10:41
Marc Vandeputte13-Sep-12 10:41 
GeneralRe: UN Register Scriptable Object Pin
Clifford Nelson13-Sep-12 11:19
Clifford Nelson13-Sep-12 11:19 
QuestionWCF error - CommunicationException: Error in deserializing body of reply message for operati Pin
vanikanc12-Sep-12 15:33
vanikanc12-Sep-12 15:33 
QuestionWpf Datagrid Pin
sudeep kushwaha12-Sep-12 2:38
sudeep kushwaha12-Sep-12 2:38 
AnswerRe: Wpf Datagrid Pin
Pete O'Hanlon12-Sep-12 3:03
subeditorPete O'Hanlon12-Sep-12 3:03 
I'm going to assume that you are using MVVM here, and I'm going to show you how to do this without needing to use a Value converter. Some may argue that this isn't pure MVVM because I'm going to put a colour in the VM, but it's not one that I would really worry about too much. Anyway, here you go - add this type of code to your VM:
C#
private const Brush greenBrush = new SolidColorBrush(Colors.Green);
private const Brush redBrush = new SolidColorBrush(Colors.Red);
private Brush currentBrush;
private int oldValue;
private int currentValue;

public Brush Background
{
  get { return currentBrush; }
}

public int CurrentValue
{
  get
  {
    return currentValue;
  }
  set
  {
    if (currentValue == value) return;
    oldValue = currentValue;
    currentValue = value;
    if (oldValue < currentValue)
      currentBrush = redBrush;
    else
      currentBrush = greenBrush;
    OnChanged("CurrentValue");
    OnChanged("CurrentBrush");
    OnChanged("Difference");
  }
}

public int Difference
{
  get { return Math.Abs(currentValue - oldValue); }
}
And that's it - bind the BackgroundValue to Background to get the background colour to respond to changes.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralRe: Wpf Datagrid Pin
SledgeHammer0112-Sep-12 11:55
SledgeHammer0112-Sep-12 11:55 
AnswerRe: Wpf Datagrid Pin
Clifford Nelson12-Sep-12 12:19
Clifford Nelson12-Sep-12 12:19 
GeneralRe: Wpf Datagrid Pin
SledgeHammer0112-Sep-12 12:27
SledgeHammer0112-Sep-12 12:27 
AnswerRe: Wpf Datagrid Pin
Clifford Nelson12-Sep-12 12:34
Clifford Nelson12-Sep-12 12:34 
GeneralRe: Wpf Datagrid Pin
SledgeHammer0112-Sep-12 13:29
SledgeHammer0112-Sep-12 13:29 
QuestionWPF groupbox visibility by combobox value selected Pin
karthik bandaru11-Sep-12 20:33
karthik bandaru11-Sep-12 20:33 
AnswerRe: WPF groupbox visibility by combobox value selected Pin
Mycroft Holmes11-Sep-12 20:54
professionalMycroft Holmes11-Sep-12 20:54 
GeneralRe: WPF groupbox visibility by combobox value selected Pin
karthik bandaru11-Sep-12 21:04
karthik bandaru11-Sep-12 21:04 
GeneralRe: WPF groupbox visibility by combobox value selected Pin
Mycroft Holmes11-Sep-12 21:12
professionalMycroft Holmes11-Sep-12 21:12 
QuestionGrid Dynamic Column and Row in run time in WPF MVVM Pin
sels198711-Sep-12 15:59
sels198711-Sep-12 15:59 
AnswerRe: Grid Dynamic Column and Row in run time in WPF MVVM Pin
Clifford Nelson12-Sep-12 13:39
Clifford Nelson12-Sep-12 13:39 
QuestionPopUp Window Open and close in WPF MVVM pattern Pin
sels19878-Sep-12 21:53
sels19878-Sep-12 21:53 
AnswerRe: PopUp Window Open and close in WPF MVVM pattern Pin
Mycroft Holmes9-Sep-12 14:25
professionalMycroft Holmes9-Sep-12 14:25 
AnswerRe: PopUp Window Open and close in WPF MVVM pattern Pin
Pete O'Hanlon10-Sep-12 5:03
subeditorPete O'Hanlon10-Sep-12 5:03 
AnswerRe: PopUp Window Open and close in WPF MVVM pattern Pin
Abhinav S10-Sep-12 16:14
Abhinav S10-Sep-12 16:14 
AnswerRe: PopUp Window Open and close in WPF MVVM pattern Pin
_Maxxx_29-Oct-12 17:30
professional_Maxxx_29-Oct-12 17:30 
QuestionTuple as a Binding Parameter Pin
Ahrimal6-Sep-12 22:11
Ahrimal6-Sep-12 22:11 

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.