Click here to Skip to main content
15,914,406 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All!

WPF is new to me, and I am stalled at a point.
I have an enum:
C#
[Flags]
public enum Toners
{
        black = 1,
        cyan = 2,
        magenta = 4,
        yellow = 8
}

and a class, that has an indexer property based on this enum:
C#
public string this[Toners toner]
{
  get
  {
    return this.TonerLevels.ContainsKey(toner) ? this.TonerLevels[toner].ToString() : String.Empty;
  }
}

Great, but I can't get any result when binding a textcolumn to it:
XML
<DataGridTextColumn Header="Black" Binding="{Binding [Toners.blank]}" Width="100" CellStyle="{StaticResource CenterCellStyle}"/>

The same snippet is working when the index is of type int, and I am referencing it as {Binding [1]}

Please guide me, how to make it work in the enum way if possible.

[Update]
I have also tried importing the namespace containing the enum directly into the xaml, and referencing the enum value both with "." and ":" notation, but still no result.

The worst is, that there is no error message either :(, only empty result. I suppose it would brig me closer, if I could increase somehow the verbosity of the xaml compilation, but I have no idea how.

Thank you.
Posted
Updated 19-Feb-13 6:49am
v2

1 solution

try this,

Binding="{Binding [(int)Toners.blank]}"

hopes this work for you.
 
Share this answer
 
Comments
Zoltán Zörgő 19-Feb-13 6:46am    
It is not working. But I am not wondering, since if this would work, my binding would work also. As I see the problem is, that the Toners.black value is not resolved in the xaml.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900