views:

33

answers:

2

I'm trying to create a custom AccordionItem that can take the tag property value "Rank":

<local:MyAccItem Header="" Content="" Rank="" /> 

This isn't really working because my control simply contains a grid that contains the original Accordion item. I have tried manipulating the template and have created a Resource file with a modified template. But the I want to change the size of Ellipse object inside the AccordionItem that I have templated so that it changes based on the rank of that item. I'm really getting stuck. Help appreciated.

+2  A: 

You need to create a Dependency Property 'Rank' in the codebehind of your MyAccItem UserControl. I'm assuming your rank would be an int? If so, you could put this in your code behind, build, then it should work in your XAML.

#region Rank (DependencyProperty)

    /// <summary>
    /// Rank
    /// </summary>
    public int Rank
    {
        get { return (int)GetValue(RankProperty); }
        set { SetValue(RankProperty, value); }
    }
    public static readonly DependencyProperty RankProperty =
        DependencyProperty.Register("Rank", typeof(int), typeof(MyAccItem),
        new PropertyMetadata(0, new PropertyChangedCallback(OnRankChanged)));

    private static void OnRankChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        ((MyAccItem)d).OnRankChanged(e);
    }

    protected virtual void OnRankChanged(DependencyPropertyChangedEventArgs e)
    {

    }

    #endregion Rank (DependencyProperty)
JSprang
trynig it out now...but what is the virtual method for?
WmasterJ
...and what is the `#region Rank` for?
WmasterJ
This worked thanks. But I didn't need all the extra stuff that I didn't understand. Such as the virtual method and `#region...`.
WmasterJ
Ok is insde by UserControl im trying to tie to this Rank property with TemplateBinding but that isn't working. I'm going crazy looking everywhere and things are shutting down on me. Is it `Binding` that I should be using? Trying now
WmasterJ
Sorry, been away for a while. Looks like you must have got this working.
JSprang
Actually it stopped working...spent hours...so strange. One minute it works another - dead. Rebuilding the proj didn't work...
WmasterJ
Not sure what to tell you without seeing how you have it implemented. We are currently using this exact implementation in all of our Silverlight controls. Let me know if you have any specific questions.
JSprang
A: 
#region Rank 
#endregion Rank 

this tags are used to encapsulate the code between them, so you can expand and collapse the code within them.

it's just to keep things organized, nothing more!

lKashef