Click here to Skip to main content
15,915,703 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Generate decimal point automatically while entering in textbox in wpf Pin
Pete O'Hanlon2-Sep-10 22:38
mvePete O'Hanlon2-Sep-10 22:38 
GeneralRe: Generate decimal point automatically while entering in textbox in wpf Pin
V.2-Sep-10 22:47
professionalV.2-Sep-10 22:47 
QuestionTrying to bind to a dependency property [modified] Pin
Christian Graus1-Sep-10 19:26
protectorChristian Graus1-Sep-10 19:26 
AnswerRe: Trying to bind to a dependency property Pin
PumbaPumba27-Sep-10 7:53
PumbaPumba27-Sep-10 7:53 
QuestionFinding a Keybinding Pin
Drathmar1-Sep-10 10:36
Drathmar1-Sep-10 10:36 
QuestionAdding custom routed event of user control to xaml of a window in wpf Pin
dashingsidds1-Sep-10 5:04
dashingsidds1-Sep-10 5:04 
AnswerRe: Adding custom routed event of user control to xaml of a window in wpf Pin
dashingsidds1-Sep-10 22:35
dashingsidds1-Sep-10 22:35 
Questionchanging skins Pin
V.1-Sep-10 4:23
professionalV.1-Sep-10 4:23 
Dear,

I'm reading Wrox WPF Programmers Reference Windows Presentation Foundation with C# 2010 and .NET 4
In chapter 16 - Themes and Skins I found following code that changes a skin at run time and attaches eventhandler for the different controls.

The Loadskin method is executed each time you select a skin from a context menu 'blue' or 'red'. I was wondering if the garbage collector removes the controls (and their handlers) at some point from memory. As I understood, the controls are re-generated each time, so if they're not collected, that could be a problem.

Note that it does say at some points 'code omitted', but the author did not mention my issue specifically so I doubt it would be there in the full code.

// Load the skin file and wire up event handlers.
private void LoadSkin(string skin_file)
{
  // Load the controls.
  FrameworkElement element =
  (FrameworkElement)Application.LoadComponent(new Uri(skin_file, UriKind.Relative));
  this.Content = element;
  // Wire up the event handlers.
  Button btn;
  Polygon pgn;
  Rectangle rect;
  Grid grd;
  Ellipse ell;
  switch (element.Tag.ToString())
  {
    case "Red":
      btn = (Button)element.FindName("btnRepairDisk");
      btn.Click += new RoutedEventHandler(btnRepairDisk_Click);
      //Code for other controls omitted
    break;
    case "Blue":
      //Lots of code omitted
      // Uses the same event handler as rectMove.
      ell = (Ellipse)element.FindName("ellMove");
      ell.MouseDown += new System.Windows.Input.MouseButtonEventHandler(rectMove_MouseDown);
      grd = (Grid)element.FindName("grdExit");
      grd.MouseDown += new System.Windows.Input.MouseButtonEventHandler(grdExit_MouseDown);
    break;
  }
}


thanks.
V.

AnswerRe: changing skins Pin
Ian Shlasko1-Sep-10 5:33
Ian Shlasko1-Sep-10 5:33 
GeneralRe: changing skins Pin
V.1-Sep-10 9:49
professionalV.1-Sep-10 9:49 
GeneralRe: changing skins Pin
Ian Shlasko1-Sep-10 10:16
Ian Shlasko1-Sep-10 10:16 
QuestionChange style of application Pin
tonydang1-Sep-10 0:38
tonydang1-Sep-10 0:38 
AnswerRe: Change style of application Pin
#realJSOP1-Sep-10 2:25
professional#realJSOP1-Sep-10 2:25 
QuestionHow to post my example Pin
tonydang31-Aug-10 23:24
tonydang31-Aug-10 23:24 
AnswerRe: How to post my example Pin
Pete O'Hanlon1-Sep-10 0:21
mvePete O'Hanlon1-Sep-10 0:21 
AnswerRe: How to post my example Pin
AspDotNetDev1-Sep-10 9:31
protectorAspDotNetDev1-Sep-10 9:31 
QuestionDate Problem in SL Pin
Jagz W31-Aug-10 21:05
professionalJagz W31-Aug-10 21:05 
AnswerRe: Date Problem in SL Pin
Pete O'Hanlon31-Aug-10 21:36
mvePete O'Hanlon31-Aug-10 21:36 
GeneralRe: Date Problem in SL Pin
Jagz W1-Sep-10 3:16
professionalJagz W1-Sep-10 3:16 
GeneralRe: Date Problem in SL Pin
Pete O'Hanlon1-Sep-10 3:17
mvePete O'Hanlon1-Sep-10 3:17 
GeneralRe: Date Problem in SL Pin
V.1-Sep-10 9:52
professionalV.1-Sep-10 9:52 
GeneralRe: Date Problem in SL Pin
Pete O'Hanlon1-Sep-10 23:03
mvePete O'Hanlon1-Sep-10 23:03 
GeneralRe: Date Problem in SL Pin
V.1-Sep-10 23:37
professionalV.1-Sep-10 23:37 
QuestionSetting the cursor for all controls Pin
dbrenth31-Aug-10 8:39
dbrenth31-Aug-10 8:39 
AnswerRe: Setting the cursor for all controls Pin
Pete O'Hanlon31-Aug-10 9:08
mvePete O'Hanlon31-Aug-10 9:08 

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.