views:

740

answers:

2

In my XAML Code I have bound the Height property of an control to the ActualHeight for it's parent control. Because I have to calculate an offset from the original value I use and IValueConverter.

Height="{Binding ElementName=MainCanvas, Path=ActualHeight, Converter={StaticResource adjustVerteilung} , ConverterParameter= 12}"

This works fine so far.

After some event the formula inside the ValueConverter does change and generates a different output. But the controls are only refreshed and aligned after I resize my window. It there any way to tell the control (from the C# code) to refresh itself and get a new value from the ValueConverter?

+1  A: 

If you add UpdateSourceTrigger=PropertyChanged to your binding, it should rebind to the value as soon as Actual height changes, instead of after the window is resized and the bindings are refreshed by MainCanvas.

Jeff Wain
A: 

I think you want to change value even if ActualHeight does not change. AFAIK the ValueConverter feature is not designed to do something like that.

You should try something different. If it is actually the observed height that you wish to update when your "some event" happens, maybe you can try building a custom panel, whose "some property" is somehow bound to your event. Then, when "some event" happens, you can change the observed height of the control(s) that lie inside the panel.

Ugur Turan