static ColorPresenter() { Colors = new ColorPresenter[140]; for(int i = 0;i < 140;i++) { byte A = (byte)((uintColors[i] & 0xFF000000) >> 24); byte R = (byte)((uintColors[i] & 0x00FF0000) >> 16); byte G = (byte)((uintColors[i] & 0x0000FF00) >> 8); byte B = (byte)((uintColors[i] & 0x000000FF) >> 0); StringBuilder builder = new StringBuilder(); foreach(char ch in colorNames[i]) { if(builder.Length == 0 || Char.IsLower(ch)) { builder.Append(ch); } else { builder.Append(' '); builder.Append(ch); } } ColorPresenter clrPresenter = new ColorPresenter(); clrPresenter.Color = Color.FromArgb(A,R,G,B); clrPresenter.Name = colorNames[i]; clrPresenter.DisplayName = builder.ToString(); clrPresenter.Brush = new SolidColorBrush(clrPresenter.Color); Colors[i] = clrPresenter; } }
public Window1() { InitializeComponent(); ColorPresenter colorPresenter = new ColorPresenter(); Binding bind = new Binding(); bind.Source = colorPresenter; bind.Path = new PropertyPath("Colors"); listBox.SetBinding(ListBox.ItemsSourceProperty, bind); //BookXmlData bkData = new BookXmlData("..\\..\\srch.xml"); //int i =5454; }