Answered How do I create a ultra light control ?

  • Wednesday, July 13, 2011 2:50 PM
     
     

    I need to create a ultralight control that consists of a rectangle with a border and a single character in side. I want to pile them upp on the screen in the thousands, a matrix of 100 x 100 if I can. I need to have a MouseOver, MouseEnter and MouseLeve event. I need to be able to move them around in a Canvas. I need to be able to sett it's background property and it's single character.

    A matrix og numbers


    I've tryed to create a control with Xaml template and deravied from Control, it's ionly good when you have a matrix of 30 x 100 when I go higher the computer gets slow and unresponsive.

    The same goes for Border and Label.

    Any Ideas ?

    Sverrir Petursson


All Replies

  • Wednesday, July 13, 2011 3:06 PM
     
     

    This is the prefect example of when using custom controls is a bad idea. Controls in Silverlight are relatively heavy by design. In your situation you should simply treat your matrix (board) as a single control. Using writeable bitmap could be another possible solution. 

  • Monday, July 18, 2011 7:57 AM
     
     Answered

    Instancing each cell is not a solution.

    Try to create just one control which renders all cells (characters) at once, depending on the position (if scrolled). 

    To get the magic done for mouse enter/leave events, you could calculate it depending on the mouse position inside your control and its offset, since you should know the size of the character cells you have.