I have a ValueConverter which needs to be called with a dynamic parameter, depending on a property. I can't see a way to do this ...
Width="{Binding ActualWidthValue, Source={StaticResource VisibleSize}, Converter={StaticResource Fraction}}"
The "Fraction" converter get's (or should get) a parameter of type System.Size, which contains a numerator and denumerator. This value (should) depend on a ItemCollection.Count. Resetting the ItemCollection should reinvoke the Converter with the new values.
My first idea was to manually change the ConverterParameter in CodeBehind on the PropertyChanged event of my ItemCollection DependencyProperty. But, as I know now, Silverlight has no GetBinding() method.
I heard about GetBindingExpression and tried to do. But MyGrid.GetBindingExpression(Grid.ActualHeightProperty) is always returning null, although the Binding is already established.
So, what can I do to reach my target?
My implementation was not much different. I set the ConverterParameter in CodeBehind just before the Converter is called via Binding. That hasn't worked (Parameter contains still the initialization value).
I'll try to use your suggestion. But why ConverterParameter can't be a DependencyPropery. What's the idea behind this? Does anybody know?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…