OK, we definitely went off the rails in this discussion as we never got around to the styling question.
For some reason you are focusing on "existing functionality" where my question is only about styling.
So when you have a control that is a composite of other controls, compiled into another assembly, how do you create a style that can be applied to that control? Do you have to name the parts of the control and target them that way?
Like I said in my other example, assume you have a UserControl a ListBox, a CheckBox, and a button, call it Widget... Widget is compiled into another assembly.
For ApplicationA I may want the background of the listbox to be red, and the button to be round. Yet for ApplicationB it could look entirely different.
If your styling is at the application level, how do those individual pieces get styled? If you just rely on TargetType, the ALL buttons would have that look. That leaves specifically targeting each individual part of the control.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
I want my entire application to have a similar look and feel; as I expect the user does.
Style the most common elements first: TextBoxes; TextBlocks; FontFamily; etc. at the "app" level.
Anchor all your elements in a dummy form / window and see how they look.
The ones that need special handling (negative margins; for example) get styles at the "level" most appropriate: element; parent element; user control; window; dll).
I'm current working on a User Control that does it's own keyboard handling; creates / deletes siblings on the fly; changes color based on "mode"; etc. In this case, I expect a lot of customizing at the control level but still expect to "inherit" colors and fonts from a "higher resource".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
I am trying to make a small "book library" application where readers can rent books.
My application is tructured like this: 4 views(with their associated viewmodels). MainWindow is the main view. Inside it i have a content control where i display the other 3 secondary/child views:HomeView, BookManagingView, ReaderManagingView. The default selected view is HomeView, where i have 2 ListViews(for Readers and Books), and some buttons. In my ReaderManagingView i have some textboxes and buttons to add/update/delete readers from database and listview.
The database has 3 tables: Books, Readers, and RentedBooks.
What i am trying to do is: when i add/update/delete users from my database, i want my changes to reflect (almost)instantly in my ListView.
The problem: The changes are visible only after i restart the application. What should i do, so that my Readers ListView updates after i add/update/delete a user?
Alternatively, as a "quick-and-dirty" approach, you could store the HomeViewModel instance passed to the ReaderManagingViewModel constructor, and call public methods on that instance to add, update and delete readers from the list.
Depending on your requirements, you could either have a single method to reload the entire list:
using (BookDBDataContext rdb = new BookDBDataContext())
ReadersList = new ObservableCollection<Reader>(rdb.Readers);
Or you could have separate methods to add, update and delete the readers: