Disclaimer: not that I cannot resolve the problem, but I'm curious why the problem occurs in the first place.
A typical scenario: placing a bunch of things within a data template into some Tag.
The end goal is to have an array of controls inside that tag.
As I'm binding to object
type property, I have to use the convertor.
<Button Content="Test" >
<Button.Tag>
<MultiBinding Converter="{StaticResource mbc}">
<Binding ElementName="sdbr"/>
<Binding ElementName="ldbr"/>
</MultiBinding>
</Button.Tag>
</Button>
The mbc
is a converter instance of this type:
public class MultiConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return values; //<--This here is a line of interest
}
... ConvertBack is default;
Now, the problem: even though input values
contains proper data, Tag
gets new object[]{null, null}
as the resulting value.
As long as I return anything different from an input array - it works just fine. All of these work properly:
return values.Clone(); /*option a*/
return new List<object>(values); /*option b*/
return values.Cast<Whatever>().ToList(); /*option c*/
I checked but couldn't find anywhere requirement to return anything except the input value on MSDN. And besides, even if such a thing would exist, why on Earth would it return me an array of proper length but with null
s inside?!