locked
Turning a grid (and contents) into a resource / control. (intclass) - 1/18/2007 11:30 PM PST RRS feed

  • Question

  • By: intclass

    I needed to make a 'custom button' from a grid (as the button itself wouldn't 
    suffice), so I did - but now I want to reuse the 'custom button' without 
    duplicating the code. Can I just set the 'custom button' (grid and contents) 
    as something I can just click and add? Or is that a pipe dream?
    
    Also (but much less important), if anyone knows, I made some of the parts of 
    the 'custom button' into resources when I was playing - any trick to undo 
    this or should I just manually reset the elements?
    Tuesday, February 19, 2008 7:41 PM

Answers

  • By: Brennon Williams

    Howdy,
    
    To apply your style to another control of the same type, you can select the 
    new button, then goto the object menu, look for Edit style, and then select 
    Apply resource from the sub menu. At the time of creating your style, or in 
    this case using the make button tool, you got the options to set the scope of 
    your resource and to store it where you wanted to, resource dictionary, 
    application etc, so just make sure your element has access to that scope if 
    you dont see your resource listed in the Apply resource list.
    
    When you created your button, you said you made some of the part resources 
    as well. There is nothing wrong with this, though you must manage the 
    resouces to ensure that all of the resources are avilable the next time you 
    want to use it.
    
    To remove them as resources, you can open any added resources in Blend or 
    find them in the markup of your application if that is where you create them, 
    and then add the appropriate properties back to your controls main resource 
    area, be it in a resource dictionary or again within the markup. This as far 
    as I know, is the only way to put the styles back in your main resource 
    template using Blend.
    
    Hope this helps.
    
    Cheers
    
    
    -- 
    http://www.expressionblend.com
    http://www.resourcedictionary.com
    http://www.x-coders.com
    
    
    "intclass" wrote:
    
    > I needed to make a 'custom button' from a grid (as the button itself wouldn't 
    > suffice), so I did - but now I want to reuse the 'custom button' without 
    > duplicating the code. Can I just set the 'custom button' (grid and contents) 
    > as something I can just click and add? Or is that a pipe dream?
    > 
    > Also (but much less important), if anyone knows, I made some of the parts of 
    > the 'custom button' into resources when I was playing - any trick to undo 
    > this or should I just manually reset the elements?
    Tuesday, February 19, 2008 10:34 PM
  • By: Adrian Mascarenhas (MSFT)

    I am assuming you made the custom button from the grid using the 'make
    button" menu option in the main menu. In that case, it would have opened a
    create resource dialog and asked you to name the button style resource.
    Once you have a resource, you can then resuse it as much as you want. Just
    draw another button on the scene, right click on it, select edit template,
    and select apply resource and choose the style resource you created earlier.
    This will apply the style to your new button.

    as for your second question, I dont think you need to reset the elements.
    You can elements within a resource referencing other resources.


    --
    - Adrian Mascarenhas (MSFT), Expression Blend
    "Content is provided "AS IS" with no warranties and confers no rights.
    Opinions are my own and do not represent those of my employer. "


    "intclass" <intclass@discussions.microsoft.com> wrote in message
    news:F57A4BC4-AD8B-4581-AAA9-78440C2E83D4@microsoft.com...
    >I needed to make a 'custom button' from a grid (as the button itself
    >wouldn't
    > suffice), so I did - but now I want to reuse the 'custom button' without
    > duplicating the code. Can I just set the 'custom button' (grid and
    > contents)
    > as something I can just click and add? Or is that a pipe dream?
    >
    > Also (but much less important), if anyone knows, I made some of the parts
    > of
    > the 'custom button' into resources when I was playing - any trick to undo
    > this or should I just manually reset the elements?
    Tuesday, February 19, 2008 10:35 PM
  • By: Jen Rowe [MSFT]

    You can also draw copies of your new button directly through using the Asset
    Popup as long as you are within the scope of where you created your custom
    button (typically the same window scene unless you specify differently)
    1. From the toolbar on the left, click the Asset Libarary button (it's the
    very last one on the bottom)
    2. Across the top of the Asset Libary popup, there are a few tabs to choose
    from, select "Local Styles"
    3. Your button style should be listed there and you can drag this to the
    scene or click on it to make it the active tool and then draw it on the
    scene.

    Jen Rowe(MSFT), Expression Blend
    "Content is provided "AS IS" with no warranties and confers no rights.

    "intclass" <intclass@discussions.microsoft.com> wrote in message
    news:F57A4BC4-AD8B-4581-AAA9-78440C2E83D4@microsoft.com...
    >I needed to make a 'custom button' from a grid (as the button itself
    >wouldn't
    > suffice), so I did - but now I want to reuse the 'custom button' without
    > duplicating the code. Can I just set the 'custom button' (grid and
    > contents)
    > as something I can just click and add? Or is that a pipe dream?
    >
    > Also (but much less important), if anyone knows, I made some of the parts
    > of
    > the 'custom button' into resources when I was playing - any trick to undo
    > this or should I just manually reset the elements?
    Tuesday, February 19, 2008 10:36 PM

All replies

  • By: Brennon Williams

    Howdy,
    
    To apply your style to another control of the same type, you can select the 
    new button, then goto the object menu, look for Edit style, and then select 
    Apply resource from the sub menu. At the time of creating your style, or in 
    this case using the make button tool, you got the options to set the scope of 
    your resource and to store it where you wanted to, resource dictionary, 
    application etc, so just make sure your element has access to that scope if 
    you dont see your resource listed in the Apply resource list.
    
    When you created your button, you said you made some of the part resources 
    as well. There is nothing wrong with this, though you must manage the 
    resouces to ensure that all of the resources are avilable the next time you 
    want to use it.
    
    To remove them as resources, you can open any added resources in Blend or 
    find them in the markup of your application if that is where you create them, 
    and then add the appropriate properties back to your controls main resource 
    area, be it in a resource dictionary or again within the markup. This as far 
    as I know, is the only way to put the styles back in your main resource 
    template using Blend.
    
    Hope this helps.
    
    Cheers
    
    
    -- 
    http://www.expressionblend.com
    http://www.resourcedictionary.com
    http://www.x-coders.com
    
    
    "intclass" wrote:
    
    > I needed to make a 'custom button' from a grid (as the button itself wouldn't 
    > suffice), so I did - but now I want to reuse the 'custom button' without 
    > duplicating the code. Can I just set the 'custom button' (grid and contents) 
    > as something I can just click and add? Or is that a pipe dream?
    > 
    > Also (but much less important), if anyone knows, I made some of the parts of 
    > the 'custom button' into resources when I was playing - any trick to undo 
    > this or should I just manually reset the elements?
    Tuesday, February 19, 2008 10:34 PM
  • By: Adrian Mascarenhas (MSFT)

    I am assuming you made the custom button from the grid using the 'make
    button" menu option in the main menu. In that case, it would have opened a
    create resource dialog and asked you to name the button style resource.
    Once you have a resource, you can then resuse it as much as you want. Just
    draw another button on the scene, right click on it, select edit template,
    and select apply resource and choose the style resource you created earlier.
    This will apply the style to your new button.

    as for your second question, I dont think you need to reset the elements.
    You can elements within a resource referencing other resources.


    --
    - Adrian Mascarenhas (MSFT), Expression Blend
    "Content is provided "AS IS" with no warranties and confers no rights.
    Opinions are my own and do not represent those of my employer. "


    "intclass" <intclass@discussions.microsoft.com> wrote in message
    news:F57A4BC4-AD8B-4581-AAA9-78440C2E83D4@microsoft.com...
    >I needed to make a 'custom button' from a grid (as the button itself
    >wouldn't
    > suffice), so I did - but now I want to reuse the 'custom button' without
    > duplicating the code. Can I just set the 'custom button' (grid and
    > contents)
    > as something I can just click and add? Or is that a pipe dream?
    >
    > Also (but much less important), if anyone knows, I made some of the parts
    > of
    > the 'custom button' into resources when I was playing - any trick to undo
    > this or should I just manually reset the elements?
    Tuesday, February 19, 2008 10:35 PM
  • By: intclass

    Never saw the "create button" feature. thanks!
    
    and thanks for everyone elses input. got it going now.
    Tuesday, February 19, 2008 10:35 PM
  • By: Jen Rowe [MSFT]

    You can also draw copies of your new button directly through using the Asset
    Popup as long as you are within the scope of where you created your custom
    button (typically the same window scene unless you specify differently)
    1. From the toolbar on the left, click the Asset Libarary button (it's the
    very last one on the bottom)
    2. Across the top of the Asset Libary popup, there are a few tabs to choose
    from, select "Local Styles"
    3. Your button style should be listed there and you can drag this to the
    scene or click on it to make it the active tool and then draw it on the
    scene.

    Jen Rowe(MSFT), Expression Blend
    "Content is provided "AS IS" with no warranties and confers no rights.

    "intclass" <intclass@discussions.microsoft.com> wrote in message
    news:F57A4BC4-AD8B-4581-AAA9-78440C2E83D4@microsoft.com...
    >I needed to make a 'custom button' from a grid (as the button itself
    >wouldn't
    > suffice), so I did - but now I want to reuse the 'custom button' without
    > duplicating the code. Can I just set the 'custom button' (grid and
    > contents)
    > as something I can just click and add? Or is that a pipe dream?
    >
    > Also (but much less important), if anyone knows, I made some of the parts
    > of
    > the 'custom button' into resources when I was playing - any trick to undo
    > this or should I just manually reset the elements?
    Tuesday, February 19, 2008 10:36 PM