I have static class with current transaction information like this:
public static class BKM
{
public static List<Ticket> Tickets {get;set;}
}
What I want to bind to Tickets.Count property in XAML.
When I type something like this
<TextBlock Text="{Binding Source={x:Static p:BKM.Tickets.Count}}" />
where p is
xmlns:p="clr-namespace:TicketApplication"
I get errors
Error 22 Nested types are not supported: BKM.Tickets.
Error 21 Cannot find the type 'BKM.Tickets'. Note that type names are case sensitive.
Error 23 Cannot find the member "Count" on the target type.
I suspect one problem is that you want the source to be BKM.Tickets
, but you want the path to be Count
. So try this:
<TextBlock Text="{Binding Source={x:Static p:BKM.Tickets} Path=Count}" />
And as Sriram says, you should make Tickets
a property as well, e.g.
public static List<Ticket> Tickets { get; set; }
You should also consider moving away from global state, which is hard to test and reason about.
See more on this question at Stackoverflow