tags:

views:

24

answers:

2

Hai guys

I extended markupextention class to set the background property of controlls my code is

public class OwnStyleExtension : MarkupExtension
{       
    public static System.Windows.Media.BrushConverter bc = new System.Windows.Media.BrushConverter();
    public static Brush brush = (Brush)bc.ConvertFrom("#00FFFF");

    public static Brush BagCol
    {
        get
        {
            return brush;
        }

        set
        {
            brush = value;
        }
    }


    public override object ProvideValue(IServiceProvider serviceProvider)
    {
        return BagCol;
    }
}

and my xaml code is

<Button Name="Btn2" Background="{local:OwnStyle}" Margin="0,105,0,122"></Button>

again i set the BagCol property in code for button click event as

BrushConverter bc = new BrushConverter();
        Brush mybrush = (Brush)bc.ConvertFrom("#00FF00");
        OwnStyleExtension.BagCol = mybrush;

The problem is, even it changes the BagCol property value it doesn't changes backgroundcolor in the button...

Can you anyone suggest me, how can i overcome this problem.

Thanks Jsiva

+1  A: 

I don't get the point of creating a custom markup extension for that... Can you give us more detail ? You could created a Style and that would be enough...

Jalfp
A: 

Thanks Jalfp

Yes I am going to load plenty of listviewitems from string xaml and those are in different different xml files for this I am going to use four colors to implement those listview items those are from this markup extention class. once i change those four colors in the markup extention class it should reflect on all those listview items. this is my purpose using markupextention.

Thanks Jsiva