I am trying to create some data binding that includes an x: Array defined in resources, but somehow it does not work even when compiling the code. In resources, I define an array of strings as follows:
<x:Array x:Key="ArrayReportType" Type="{x:Type sys:String}">
<sys:String>Energy Export</sys:String>
<sys:String>Cost Center Report</sys:String>
</x:Array>
I also have a collection of objects. One of the properties is called "ReportType" and is an integer / enumeration. Therefore, I would like to do data binding to show the corresponding line in ReportType instead of int / enum. I tried this line, but it does not work (the second line calls pb):
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Type"
Binding="{Binding Source={StaticResource ArrayReportType}, Path=[{Binding ReportType}]}" />
I'm sure I'm close to a solution. If I write directly "Path = [1]", then this is correct. At runtime, I get this error:
System.Windows.Data error: 40: BindingExpression path error: property '[]' not found in 'object' '' String [] '(HashCode = 14199578)'. BindingExpression: Path = [{Binding ReportType}]; DataItem = 'String []' (HashCode = 14199578); target element is "TextBlock" (Name = ''); target is "Text" (type "String")
Any help would be greatly appreciated.
source
share