locked
Objects not disposed after override style RRS feed

  • Question

  • Hi,

    I have used a popup in my silverlight control which contains border, Grid, ScrollViewer etc. I will open this popup in some scenarious and i will change the style of the control using another resource dictionary.While changing the style i will OverWrite the existing objects with the current style in OnApplyTemplate(). Now when i open the popup both the old and current styles getting opened. Please guide me on this issue.

     

    Thanks for any help..

    Tuesday, September 7, 2010 4:33 AM

Answers

  • Hi,

    This forum is for WF4.0 only, you should post this question in Sliverlight forum:
    http://forums.silverlight.net/

    Thanks


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com
    • Marked as answer by Andrew_Zhu Tuesday, September 14, 2010 6:58 AM
    Thursday, September 9, 2010 6:05 AM

All replies

  • Hi angsindia,

    There is a prioroty order in styling :

    1. Property
    2. Style affected buy key
    3. Style affected by type

    If you are using a style and a propoerty, the property will have priority. You have to remove properties affected if you want use styles.

     


    Jérémy Jeanson MCP, MCTS http://blogs.codes-sources.com/JeremyJeanson/ (French or English spoken)
    Tuesday, September 7, 2010 7:45 AM
  • Hi Jeremy.Jeanson,

    Thanks for your reply.

    My actual scenario is after rendering the control i will open the popup which contains Grid,Border & Scroll Viewer etc.. While rendering the control i did some implementation using the template childs of the popup by using the below code in OnApplyTemplate() method of my class.

    this.PART_TopScroll = this.GetTemplateChild("PART_TopScroll") as Button;

    this.PART_BottomScroll = this.GetTemplateChild("PART_BottomScroll") as Button;

    this.PART_ScrollViewer = this.GetTemplateChild("PART_ScrollViewer") as ScrollViewer;

    this.PopUpGrid = this.GetTemplateChild("PopUpGrid") as Grid;

    this.PopUpBorder = this.GetTemplateChild("PopUpBorder") as Border;

    Now when i change my theme, so again OnApplyTemplate() will be called and the current template childs will be assigned to the same objects. By Default it will overwrite the old objects. but in my case if i open the popup now its showing both the current template childs and old template childs.

    a)Please guide me on how to dispose that old objects.

    b)Also i have used ContentControl inside the popup and placed a object inside that. After change the theme when i open the popup its showing the following exception. Please guide me on this issue also.

    Error: Unhandled Error in Silverlight Application
    Code: 2531   
    Category: ParserError      
    Message: Failed to assign to property 'System.Windows.Controls.ContentControl.Content'.    
    File:     
    Line: 357    
    Position: 170

     

    Thanks.

    Wednesday, September 8, 2010 11:21 AM
  • Hi,

    This forum is for WF4.0 only, you should post this question in Sliverlight forum:
    http://forums.silverlight.net/

    Thanks


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com
    • Marked as answer by Andrew_Zhu Tuesday, September 14, 2010 6:58 AM
    Thursday, September 9, 2010 6:05 AM