I believe is is probably a bug in VS where is the xaml is too complex and it fails to render it. As irritating as it is I have never bothered to try and resolve the issue as it rarely happens and the resolution would probably take too much time anyway.
I now try and keep a views complexity down
Never underestimate the power of human stupidity
When I run it, I see Resize handles on all 4 corners of the textbox, and I can click & drag. The problem is that I cannot edit the text in the text box because the IsHitTestVisible property on the textbox Is False.
Set IsHitTestVisible = true and you can no longer drag & resize.
What I'd like is to be able to both drag/drop AND edit.
i am displaying the result of this linq query in a wpf datagrid
var v = from p in _context.EXAMENS_VALEURs
join b in _context.EXAMENS_TYPES_VALEURs on p.EXV_ID_VALEUR_TYPE equals b.ID_EXAMEN_TYPE_VALEUR
join c in _context.EXAMENS_TYPES_GROUPEs on b.EXTV_ID_GROUPE equals c.ID_EXAMEN_TYPE_GROUPE
ID = p.ID_EXAMEN_VALEUR,
Designation = b.EXTV_DESIGNATION,
Groupe = c.EXTG_DESIGNATION,
Valeur = p.EXV_VALEUR
((CollectionViewSource)this.FindResource("ExamensView")).Source = v.ToList();
I assume your model implements INotifyPropertyChanged Interface. In your VM, you can subscribe to the model's property changed event, and then check if the IsChecked property is the one being changed. If the instance of the model is inside a collection (I assume it is as this is a hierarchicaltemplate), you will need to subscribe to the collection's collection changed event, then inside that method, you subscribe to each instance's property changed event.
Something like this
Items.CollectionChanged += ItemsChanged;
privatevoid ItemsCHanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
if(e.NewItems != null)
foreach(Item item in e.NewItems)
//Subscribe to property changed
item.PropertyChanged += ItemChanged;
if (e.OldItems != null)
foreach (Item item in e.OldItems)
//Ensure you unsubscribe
item.PropertyChanged -= ItemChanged;
privatevoid ItemChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
if(e.PropertyName == "IsChecked")
//Do work here
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
I think the best thing to do is to convert the xaml headers, like DataGridTextColumn to equivalent classes in C#. The red items in xaml are the properties for that class. For example, the Header and IsReadOnly is most likely in the original DataGridTextColumn class as additional properties. Most xaml headers can be located as similar class names. Finally, the binding could be changed to reference the DataGrid's name instead.
Although answered in the above post, I will say this:
To me, the word "service" screams static class. What use is a service if you have to create it and register all your views every time you are in a different scope? I would create the service class as a static item and register views on it, that way the registered views are available to the entire application without having to recreate the registry.
You would have to use some kind of initialization logic to set up the service (register all the available views) that should be called during the startup process of your program.
privatestatic Dictionary<Type, Type> registry = new Dictionary<Type, Type>();
publicstaticvoid RegisterView(Type dialogType, Type viewModelType)
//Rest of the implementation here
publicstaticbool? ShowDialog<TViewModelType>(TViewModelType viewModel) where TViewModelType : DialogBaseViewModel
//Rest of the implementation here
You don't seem to be using the TDialogType anywhere (you could replace it with "Window" in the RegisterView and ShowDialog methods and get exactly the same effect). There is no reason that I see that you need type parameters on the class itself where the type parameters on the method work fine (you only need them if you were using your dictionary as TDialogType,TViewModelType, which you aren't.
Last Visit: 31-Dec-99 18:00 Last Update: 9-Aug-22 9:40