Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Binding to ConverterParameter

Open RomanSoloweow opened this issue 2 years ago • 10 comments

  <toolBox:ToolBoxItemView  IsVisible="{Binding $parent[views:EventView].EventType,
                                               Converter={StaticResource PopurTypeVisibleConverter}, 
                                               ConverterParameter={Binding $self.Type}}"/>

I expect ConverterParameter to work like CommandParameter. But instead of the value, I get a Binding instance

RomanSoloweow avatar Nov 02 '21 10:11 RomanSoloweow

image

RomanSoloweow avatar Nov 02 '21 10:11 RomanSoloweow

I expect ConverterParameter to work like CommandParameter.

Why? It works exactly the same as on WPF and probably also on WinUI. What you ask for is a feature request, not a bug.

Symbai avatar Nov 02 '21 11:11 Symbai

Yes, it works like that in both WPF and WinUI. Though it would be nice to have anyway. Right now, it's possible to use MultiBinding instead.

maxkatz6 avatar Nov 02 '21 20:11 maxkatz6

@maxkatz6 Am I correct in understanding that it is enough to change the ConverterParameter type to DirectProperty for this?

RomanSoloweow avatar Nov 02 '21 22:11 RomanSoloweow

@grokys, @kekekeks

Looking at #6865, it seems like I'm not the only one who needs this function. What do you think about this?

RomanSoloweow avatar Nov 05 '21 04:11 RomanSoloweow

Ran into the same issue where the ConverterParameter needs to receive a view model instance.

AcidJunkie303 avatar Jan 05 '22 07:01 AcidJunkie303

I would also be happy if this function would be implemented. 👍

djonasdev avatar Feb 09 '22 09:02 djonasdev

Yes, it works like that in both WPF and WinUI. Though it would be nice to have anyway. Right now, it's possible to use MultiBinding instead.

Well yes and no. MultiBinding doesn't allow TwoWay, nor gives you a ConvertBack method, so its scope is a bit limited. Personally, i would need exactly that, and it would be perfectly fulfilled through the binding of the ConverterParameter.

MarcoMuellner avatar Mar 29 '22 12:03 MarcoMuellner

I ran into the same issue, anyone knows how to extract the actual value from the binding instance? It would be nice indeed to implement this feature

Energizer188 avatar Oct 31 '22 11:10 Energizer188

extract the actual value from the binding instance?

You can't. For now, use MultiBinding if you don't need convert back value.

maxkatz6 avatar Oct 31 '22 21:10 maxkatz6