UserControl Property binding issues

74 views Asked by At

I have a view where I integrate a UserControl several times.... the text gets binded and propertyChanged occurs. all good. But BorderBrush never changes.. also ShiftID and BoxName are always null.

I'm not sure what I'm missing out here.. been playing around and reading stuff all day now. no solution yet.

Some suggestions would be very helpful.

1

There are 1 answers

0
Olaru Mircea On

I am not sure how you instantiate that BorderBrush property but for me it did work like this:

     public Brush BorderBrush
    {
        get { return (Brush)GetValue(BorderBrushProperty); }
        set { SetValue(BorderBrushProperty, value); }
    }

    // Using a DependencyProperty as the backing store for BorderBrush.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty BorderBrushProperty =
        DependencyProperty.Register("BorderBrush", typeof(Brush), typeof(MainWindow), new PropertyMetadata(null));

This instantiation takes place after the InitializeComponent:

BorderBrush = new SolidColorBrush(Colors.Green);

And at some point i have a Button Click handler where i change it:

(BorderBrush as SolidColorBrush).Color = Colors.Red;

I am not sure if this aims your target but i didn't see your instantiation and i thought this might be a solution..