public EntryDetailViewModel(CountEntry countEntry)
        {
            this.RegistryKey = countEntry.RegKey + "\\" + countEntry.Name;

            StringBuilder hexValue = new StringBuilder();
            int i = 0;
            foreach (byte b in countEntry.Value)
            {
                hexValue.AppendFormat("{0,2:X2} ", b);
                if (++i % 8 == 0) hexValue.AppendLine();
            }
            this.Value = hexValue.ToString();
        }
        private void OnSearch()
        {
            countEntries.Clear();

            RegistryKey reg = Registry.CurrentUser.OpenSubKey(SelectedSourceType.Key);
            foreach (string valueName in reg.GetValueNames())
            {
                CountEntry entry = new CountEntry();
                entry.Name = valueName;

                // filter by name
                if (!string.IsNullOrEmpty(NameFilter))
                {
                    if (!entry.DecodedName.ToUpper().Contains(NameFilter.ToUpper())) continue;
                }

                entry.Value = (byte[]) reg.GetValue(valueName);
                entry.RegKey = reg.ToString();
                entry.PropertyChanged += (o, e) =>
                {
                    CountEntry countEntry = (CountEntry)o;
                    if (e.PropertyName == "ExecutionCount")
                    {
                        try
                        {
                            byte[] newCount = BitConverter.GetBytes(countEntry.ExecutionCount);
                            newCount.CopyTo(countEntry.Value, 4);
                            Registry.SetValue(entry.RegKey, entry.Name, entry.Value);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error Updating Registry: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    else if (e.PropertyName == "DeleteCommand")
                    {
                        CountEntries.Remove(countEntry);
                    }
                };
                countEntries.Add(entry);
            }
        }
 public EntryDetail(CountEntry countEntry)
 {
     InitializeComponent();
     DataContext = new EntryDetailViewModel(countEntry);
 }