private void DGEditStyleTmpl_LostFocus(object sender, RoutedEventArgs e)
 {
     //System.Windows.Forms.MessageBox.Show("lost");
     try
     {
         PropertyGridItem item = PropertyGrid.SelectedItem as PropertyGridItem;
         if (sender is TextBox)
         {
             string txt = (sender as TextBox).Text;
             item.SetValue(txt);
         }
         else if (sender is CheckBox)
         {
             var b = sender as CheckBox;
             item.SetValue(b.IsChecked);
         }
         UpdateProperty(item);
     }
     catch (Exception ex)
     {
         // e.Cancel = true;
     }
     finally
     {
         PropertyGrid.Items.Refresh();
     }
 }
 private void ColorPicker_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs <Color?> e)
 {
     try
     {
         PropertyGridItem item = PropertyGrid.SelectedItem as PropertyGridItem;
         if (item != null)
         {
             if (sender is ColorPicker)
             {
                 var b = sender as ColorPicker;
                 item.SetValue(b.SelectedColor);
                 // Debug.WriteLine("=> Selected = " + b.SelectedValue + ":" + b.SelectedValue.GetType().Name);
                 //  Debug.WriteLine("=> Sett = " + item.ValueAsKey + ":" + item.ValueObj.GetType().Name);
                 UpdateProperty(item);
                 //PropertyGrid.Items.Refresh();
             }
         }
     }
     catch (Exception ex)
     { }
 }