I'm new to Windows Phone 8 development. I've been working with it for about a month now and have written my own news app consuming data from an API. I save article content offline into the app's local storage as .json files. Since I have already them saved offline I want to give my users the ability to 'save' that article to a list of favourites and have one of my pivot items show the list of saved articles for them to access later. I also want that list manageable by the user i.e. I want them to be able to delete the items as necessary.
I'm planning on loading the data context for the list using an object called:
SavedArticles
which is simply a
List<Article>
I've read a lot about how to update the current view using INotifyPropertyChanged, but I think that is more about updating properties of existing items in the list. What I need is something that can update the ItemsSource after the user selects an item and then clicks delete in the AppBar. I think that is where INotifyCollectionChanged should come in, but for the life of me, I can't see how to implement it.
Looking for someone to enlighten me or point me at a great example.
I have Googled this to death but cannot find many examples and the ones I have seen, I'm just not getting.
Thanks!
Instead of using List<Article> use an ObservableCollection<Article> (from System.Collections.ObjectModel) as this implements INotifyCollectionChanged.
This means that when you remove an item from the underlying collection (which is what your delete function should do) then this will be reflected in the databound UI collection.
Related
It seems, that Janusys isn't active anymore. The Forum Posts get not answered since a while. In my application (Winforms!), I use there controls since a couple of years. Now I want to extend my application with the schedular Control.
I found a Sample within the Janus Software, where they "explain", how the Control can be used, in DataBound mode.
The Problem there is, that this example works with DataSet / TableAdapter.
This I don't want to use, because I use in my whole application LinQ.
Now, I tried to move on, with there sample application and rewrite it, so I can use LinQ. But I am not able to get it working.
I use BindingSource to bind my data via LinQ from the database to the Control. This works really fine and all saved Appointments get displayed as expected.
But...
I am not getting it working, to create/update Appointments.
1) The BindingSource AddNew Handler is fired, but with "NewObject" is Nothing
2) I don't know, how I get an existing Appointment verified, that this one is already saved in database, or if it is a new Appointment.
Does anyone could help me with this Problem and can explain, how I can do it Right, without using DataSet/TableAdapter?
THX a lot in Advance
THX a lot for everyone, who looked into it.
I found a solution, which looks to work fine.
I have to add all appointments with a ForEach Loop and remove the BindingSource completly.
Then I can add the Key Value, and from there, it is easy, because, I am able to see, if this is already an existing appointment (then the key has a value) or even not.
THX - Have a nice evenenig
I have a questions that is more theory of "best practices" than actual technical programming.
I am trying to think of the best way to handle editing an element after it is placed by my program. Specifically I have my program set up as follows:
User clicks a tool that essentially "adds some families into a project" in Revit. It reads a sketch created by user and places items based on the sketch.
Sketch
Element creation
I want to give the user the ability to "edit the sketch" of those elements similar to say a floor slab. I don't believe the Revit API exposes the ability to sketch using "sketch mode". I am trying to mimic this very useful capability in my program.
So, what I have done is used extensible storage and store an UniqueId into all elements created using my tool. What the program does is when the user clicks "edit elements" tool, the program asks for the new sketch, asks to click on existing element, reads the UniqueId of the existing element and calls all elements with that UniqueId and deletes them, then the program adds new elements into the project again using the users "new sketch".
The problem is, if the user deletes the original elements that were added to the project and then tries to edit them, how do I guarantee the user is not going to delete those original elements that have the UniqueId? I think the way to go is to use the Dynamic Model Update functionality in the Revit API.
How are most of these algorithms written? Am I on the right track here? Do I just assign UniqueIds to elements and store them on the elements themselves so I can call them up later? Maybe there is a basic theoretical piece of the puzzle I am missing. Data structures?
I think you are essentially on the right track.
Using extensible storage to store the UniqueIds is definitely the way to go, and also using the DMU dynamic model updater functionality to react to changes sounds good.
The one thing that seems to be unclear is the fact the Revit will automatically assign the unique ids to the elements when they are created, and there is nothing you can do to affect that. The unique id is unique and immutable, and you have no control over it.
Therefore, the easiest approach is probably to delete all the previous sketch elements and recreate the entire sketch and all elements defining it from scratch whenever the sketch needs to be modified in any way.
You should use ElementId instead of UniqueId for structured storage, because an ElementId is automatically remapped to the new ElementId when a work sharing update occurs. The ElementId is also set To ElementId.InvalidElementId when the element is deleted.
I need help. I am currently building data management applications using Winforms and C#. This application has been installed on 10 computers and are connected to one database on the server. Network only in the office.
These applications use the data grid view to display a list of employees.
The main problem now, if users on PC-A has entered a new record or update employee records, data grid view on PC-B is not updated automatically. So if I want to refresh the data grid view on PC-B, I need to press the "REFRESH" button to reload the record.
So the question is now, there are other ways to 'Data Grid View' can be updated automatically?
I do not know what it is named this method, so I hope there is anyone willing to help me in solving this problem. If the my question is already exist, hope someone can give me a link.
Thanks for help :)
In order to achieve what you want, you will need to do some fairly complex architecture work. There is no simple fix here, I am afraid.
The problem is that you want your data girds to update based on an EVENT, however that event occurs outside the application in the database. In order to register that EVENT, you will need to have a class or service which is responsible for handling all INSERTS/UPDATES/DELETES.
If you define all of your tables or views as ARTICLES, you could then have a Publisher / Subscriber model. The Data service would handle all the inserts updates and deletes for the application, and push notifications that an ARTICLE has changed to all the Subscribers for the article. On each page you could have a Class which subscribes to an Article which relates to the data displayed on your data grid, and when it receives a message that the article has been updated, rebinds the data grid to the data source.
Try reading this WIKIPEDIA article on the Observer pattern to get an idea of what the architecture might look like.
http://en.wikipedia.org/wiki/Observer_pattern
You can add Version column to a data base table, then you should ask data base periodically (pooling) to get records with has a greater version than a last received
I am trying to catch the save event on listviews, not the list itself. This is so that i can stop saving of certain views.
I have tried List SPListEventReciever, but this seems to only catch events on the list itself, not the views.
EDIT: As mentioned in comment below, the views im trying to stop people saving are the default views on external lists.
In your situation, I'd try the following:
Remove regular users' permission to modify lists at all (if this is acceptable). This should still let them create personal views.
Write code that will take a personal view, analyse it, (delete it?) and (using elevated privileges) create an equivalent public view. (You can't just change the PersonalView property, sadly.) Be careful to capture everything a user can do on the create-a-view UI - this will be the trickiest part.
Optionally write similar code to allow a view to be switched from public back to personal (checking it's not the default view or any other view you're trying to protect.)
Optionally keep track of who "owns" one of these custom views, for example in a hidden list, and only allow the owner to take a view back to personal.
Write an interface to this code, e.g. an application page allowing a user to select from the relevant views, or a custom action on the ribbon.
I am using ASP.NET and Razor to create a calendar application similar to Google calendar and was hoping to get some feedback on my design thus far. My idea is to have 2 tables, one normal table for users, and another for a table of events which will store the users id and the time of the event, event ID, name of the event, and duration of the event.
I plan to write some code that will display a calendar on screen and allow the user to select multiple times so as to mark them as busy and give them a name. When this is done, the user submits the information and it is inserted into the database.
What is the best way to go about tackling this calendar construct? I can't really think of a simple way. I am guessing I can create a nice looking calendar using HTML and CSS, and perhaps JS to allow the drag and drop functionality? I suppose when the user selects a time, an object would be created with a start time and default duration, then when they drag it the duration changes. I am confused by how you would do this however, pulling objects out of thin air. How does Google Calendar do this?
And then how do you store all of the created objects in the database? I am guessing that Razor has a foreach construct and that I could just iterate over all objects created and insert them into the database one-by-one?
Also, how could I clean up the database, garbage collecting events that have already transpired while keeping events that are constant ie daily/weekly?
Apologies if the question is vague, if it is too vague then please press me on details I can be more clear on rather than close this. Thank you.
What is the best way to go about tackling this calendar construct?
If you are wondering about data structure here, whatever you do, do it in that way that it makes it compatible with standard iCalendar standard
I can't really think of a simple way.
Calendars are quite complex applications, there is no simple way. (events, sharing events, tentative, attendants, reminders...)
I am guessing I can create a nice looking calendar using HTML and CSS, and perhaps JS to allow the drag and drop functionality?
Yes.
I suppose when the user selects a time, an object would be created with a start time and default duration, then when they drag it the duration changes. I am confused by how you would do this however, pulling objects out of thin air. How does Google Calendar do this?
You can find some existing jquery plugins for this (try with this for start, or take a look at this list).
And then how do you store all of the created objects in the database? I am guessing that Razor has a foreach construct and that I could just iterate over all objects created and insert them into the database one-by-one?
Check out these jquery plugins and see how do they communicate with the server side. You will end up making ajax requests and then making database queries in the database. Razor has nothing to do with database...also Razor has nothing to do with client side interaction, it just renders page and everything else is on the js side.
Also, how could I clean up the database, garbage collecting events that have already transpired while keeping events that are constant ie daily/weekly?
I would't delete anything from database...don't see a reason for that. Just grab all you have and fill in the calendar. User will always look at month/date/week...grab data for that period and show it. When he goes back one year, he will have all the data still available.
Have you met my friend, Google?
In particular, 4GuysFromRolla has a tutorial, and there is a nice looking open source calendar control with some tutorials that should get you well on your way.