|
crashdome posted:I don't mean to be a jerk but, you didn't read my post fully or you actually didn't try it. What I proposed needed to be done, cannot be done. My apologies, I focused in too hard on the "base window" part of things. GrumpyDoctor posted what I would have recommended (subscribing in the constructor), though since you mentioned you have a base ViewModel I would probably change it to something like: C# code:
|
# ? Mar 19, 2015 04:31 |
|
|
# ? Jun 1, 2024 09:38 |
|
Yeah I also assumed the event subscription in constructor was an implicit impetus for wanting the base class, and it was more of a syntactical question of how to do the inheritance. I do suggest using a proper method rather than a lambda to handle the event, so you can also unsubscribe. Adhemar fucked around with this message at 05:50 on Mar 19, 2015 |
# ? Mar 19, 2015 05:47 |
|
No problem. And that's a good point. I'll do proper checking of type, make sure proper method is called, and handle the events appropriately. Thanks everyone for the help. Ultimately, I have a ViewModelBase and a derived class called EditorViewModelBase which further adds some normally boilerplate to handle fully cleaning up the ViewModel instance (Unregistering it from Service Locator) for garbage collection and also notify the application that certain lists have been edited and need to be refreshed on anything currently visible (like a selection dropdown/combobox). Best place to handle it was Closing event. When I had 4 editors it was nothing to maintain... I'm looking at close to a dozen now and climbing. It's tedious XAML work. All of them have the same buttons usually (New,Delete,Edit,Save,Cancel) which was easy through ControlTemplates as someone suggested but the Closing event.... ugh. e: Oh, and my Main application window and my generic dialog ViewModels also use the Closing event. So basically anything NOT a User Control crashdome fucked around with this message at 07:04 on Mar 19, 2015 |
# ? Mar 19, 2015 06:59 |
|
Xamarin announced a bunch of things at dotnetConf, including a preview verison of Xamarin.Forms for WinRT, and updates for Android Wear/Apple Watchkit/Microsoft Band. Also if you're in an OSS project, you can now apply to get a free Xamarin license to port your stuff over. It's about time, seeing that there would be little incentive for most people to buy a license to port their free OSS project over. Note that I have no idea of what will actually get accepted. All I know is that it needs to be "established", meaning you can't just throw something up on Github and apply. Also note that I did not come up with that web form. I don't know who made it, but man is it ugly . Drastic Actions fucked around with this message at 18:30 on Mar 19, 2015 |
# ? Mar 19, 2015 17:48 |
|
That looks cool. Has anyone used the VS plugin for Xamarin? I am actually pretty interested in it, but you need an subscription. I just wanted to test it out and create an Windows Store app.
|
# ? Mar 19, 2015 18:16 |
|
I think they have a 30 day trial. I use the VS plugin for iOS development and it generally works pretty well. It used to be a lot buggier 6-12 months ago, but I find it's pretty stable now.
|
# ? Mar 19, 2015 18:18 |
|
Mr Shiny Pants posted:That looks cool. Has anyone used the VS plugin for Xamarin? I am actually pretty interested in it, but you need an subscription. I just wanted to test it out and create an Windows Store app. For iOS it can be a pain, but gets better with each new release. At the very least, it's more reliable for me so I don't have to keep reconnecting the build tool. Also having Resharper in VS helps tons too (and it's also compatible with Xamarin, including Forms XAML support). Android support has always been fine for me. You can try it out for 30 days, but the VS plugin only works on Business accounts and up. And that's a lot of money. For the indie license you can usually haggle the sales team and get a discount, but you only get to use Xamarin Studio. Which is not bad (especially after you turn on all the code complete/folding options) but... yeah, despite what my coworkers say, it's no Visual Studio.
|
# ? Mar 19, 2015 18:30 |
|
Drastic Actions posted:For iOS it can be a pain, but gets better with each new release. At the very least, it's more reliable for me so I don't have to keep reconnecting the build tool. Also having Resharper in VS helps tons too (and it's also compatible with Xamarin, including Forms XAML support). Android support has always been fine for me. Ok, so a quick POC for Android using VS is out of the question for personal use. That's a shame. I'll see about Xamarin studio, I have it installed but like you said, it is no VS.
|
# ? Mar 19, 2015 18:42 |
|
crashdome posted:Oh man, I remembered this from way back and I had to google a little but, I think I found the solution. I simply remembered that it was configurable options of the OpenFileDialog control and this person seems to have documented them: This actually helped me with one of my projects where the user has to select a directory to scan and we wanted the ability to type a path instead of always navigating to the folder. Thanx!
|
# ? Mar 19, 2015 20:42 |
|
I have a problem getting the Standard Styles in my WinRT app. I like the way the buttons from MS look and would like to use the defaults styles. These seem to defined in generic.xaml and my template reference them. If I want to use them myself the xaml editor can't find the static resource. Anybody know what is going on?
|
# ? Mar 19, 2015 21:24 |
|
Can I use File.Copy to copy directories, or should I be looking at something else? I noticed it says the destination source can't be a directory, but I can work past that, Maybe a better way to ask this is- my application lets users select either files or directories and the plan is to then copy said selected files/directories to user-specified locations. Is File.Copy what I should be using? TheEffect fucked around with this message at 23:58 on Mar 19, 2015 |
# ? Mar 19, 2015 23:55 |
|
TheEffect posted:Can I use File.Copy to copy directories, or should I be looking at something else? I noticed it says the destination source can't be a directory, but I can work past that, You can use the Directory class to enumerate the files in a directory (and create the desination directory) and then yes, File.Copy them to the destination. There is also a FileSystem class that has a CopyDirectory method: https://msdn.microsoft.com/en-us/library/ms127957%28v=vs.110%29.aspx Never used it myself but may be a more direct route. The FileSystem method might include all subfolders and files, so you'll want to check that.
|
# ? Mar 20, 2015 01:10 |
|
The FileSystem method is exactly what I needed. Thank you sir!
|
# ? Mar 20, 2015 03:31 |
|
So is MVVM kinda crap or what? I am a little frustrated. So my data has a couple of collections that represent a hierarchical data scheme. So in the beginning I just had a view model and no model because it is just a small app. Now for serializing my data I use json.net and want to serialize my viewmodel to disk. For persistence but also for suspend/resume of a tablet. The problem is all the extra attributes on the viewmodel that don't need to be in the json file. So first round: I've annotated my classes with [datacontract ] and [datamember] this gets me much better control of my json serializing. The problem is that my data has a class hierachy in an ObservableCollection. Normal deserializing breaks. Everything is the baseclass. Second round: Create a json setting that includes type information. This works except for ObservableCollections. I get an assembly load error. So now I am thinking of copying the data to a class specifically for serializing/deserializing. Creating a list and load the Observables in there etc. etc. Now this is beginning to look like a model...... So now I am thinking of building a model but reading some more about it, wow. How to keep lists -> ObservableCollections in sync? I can build Proxy classes, implement InotifyProperty changed, wrap my models and bind the attributes directly etc. etc. MVVM is 2006 -2007 right? Why is this so hard in 2014? Mr Shiny Pants fucked around with this message at 20:26 on Mar 20, 2015 |
# ? Mar 20, 2015 20:12 |
|
Hark! An error in the logs!quote:EntityException: An exception has been raised that is likely due to a transient failure. If you are connecting to a SQL Azure database consider using SqlAzureExecutionStrategy. Apparently once in a while Azure Websites inexplicably drop connections to Azure SQL Servers. This happens often enough that they've written a BandaidThisHugeProblem class (cleverly named SqlAzureExecutionStrategy) to retry the connection if it drops. Here's how to use it: http://entityframework.codeplex.com/wikipage?title=Connection%20Resiliency%20Spec Simple, enough, just add this to the same assembly as your DbContext: C# code:
But wait, here's a workaround https://msdn.microsoft.com/en-US/data/dn307226 C# code:
C# code:
OR Why is it this hard to write a reasonably robust application? OR Why don't they just figure out what's wrong with the connections between Azure Websites and Azure SQL Servers? </rant> epswing fucked around with this message at 20:35 on Mar 20, 2015 |
# ? Mar 20, 2015 20:17 |
|
Mr Shiny Pants posted:So is MVVM kinda crap or what? I think you're conflating the ideas of your ViewModel and your Model. The data you want to serialize is your Model, not your ViewModel. The ViewModel exists solely as a representation of the Model for use in your UI. Your Model should contain all of your relevant logic, and it should be decoupled enough from the View and ViewModel that you could reference it in a console app and interact with it there.
|
# ? Mar 20, 2015 20:25 |
|
epalm posted:Hark! An error in the logs! We've run into this exact issue a number of times. The problem isn't really inexplicable, just hard to solve. Azure SQL instances aren't tied to a specific VM and they can and will be re-shuffled around as necessary for load balancing. This interrupts your database connection. We saw that we were doing a bunch of stuff to get Azure happy with transactions, so we ended up making our own wrapper around Transaction that implements IDisposable. That would probably also work for you, and you could set SuspendExecutionStrategy = true in the constructor and false in the Dispose implementation.
|
# ? Mar 20, 2015 20:33 |
|
Bognar posted:I think you're conflating the ideas of your ViewModel and your Model. The data you want to serialize is your Model, not your ViewModel. The ViewModel exists solely as a representation of the Model for use in your UI. I think I understand it ok enough, so how do I keep my viewmodel and model in sync if something changes due to the gui? Let's say my model and view are: code:
Even for a single attribute: Do I wrap them? code:
It's an honest question. InotifyPropertyChanged on all my Model attributes? Mr Shiny Pants fucked around with this message at 20:36 on Mar 20, 2015 |
# ? Mar 20, 2015 20:34 |
|
Bognar posted:We've run into this exact issue a number of times. The problem isn't really inexplicable, just hard to solve. Azure SQL instances aren't tied to a specific VM and they can and will be re-shuffled around as necessary for load balancing. This interrupts your database connection. It was inexplicable to me, until now. If that's really the case, good lord almighty, noon on Saturday is not a great time for a service interruption, which we're generally told about weeks in advance.
|
# ? Mar 20, 2015 20:37 |
|
Mr Shiny Pants posted:Now my GUI fires a command to update the person's email address? Which list do I update and how do I keep them synced? Sync as necessary. Sometimes you need to get data into the Model right away, other times it's fine for the change to sit in the ViewModel until the user clicks Save or equivalent.
|
# ? Mar 20, 2015 20:40 |
|
Mr Shiny Pants posted:It's an honest question. InotifyPropertyChanged on all my Model attributes? It depends. You only really need INPC to be implemented if the viewmodel is going to be manipulating the model during the lifetime of the view. If the model is only being changed via view interactions, you can do a one-way databinding. Easy answer: Just make a base class that implements INPC and derive models from it.
|
# ? Mar 20, 2015 20:41 |
|
Ithaqua posted:It depends. You only really need INPC to be implemented if the viewmodel is going to be manipulating the model during the lifetime of the view. If the model is only being changed via view interactions, you can do a one-way databinding. epalm posted:Sync as necessary. Sometimes you need to get data into the Model right away, other times it's fine for the change to sit in the ViewModel until the user clicks Save or equivalent. I can see why they invented Automapper.
|
# ? Mar 20, 2015 20:45 |
|
Mr Shiny Pants posted:Now my GUI fires a command to update the person's email address? Which list do I update and how do I keep them synced? Usually I just do a full Refresh on my ViewModel when I expect data will change. If that causes performance problems I change it, but it so rarely does. If there's global data that changes (e.g. multiple views need to update) then I'll create a custom event that all interested ViewModels can subscribe to. In your example, the command to update the email address would update it on the Model alone, then trigger the ViewModel to be refreshed. The ViewModel would inspect the Model, and update its properties based off the Model. Every ViewModel should know how to build itself from the Model it represents. This is just the way that I do it, but it makes things really easy to reason about. Some UI interaction changes the Model, the ViewModel is rebuilt based off the Model, the Views update from the ViewModel's PropertyChanged events firing.
|
# ? Mar 20, 2015 20:45 |
|
Mr Shiny Pants posted:I think I understand it ok enough, so how do I keep my viewmodel and model in sync if something changes due to the gui? Mr Shiny Pants posted:I can see this working for attributes but not for collections.
|
# ? Mar 21, 2015 00:34 |
|
GoodCleanFun posted:Your properties can have getters returning your models properties. You then update your models emails addresses when you get that command. So I wrap my model properties within my viewmodel properties right? So if I need to instantiate a new listitem in my model and also my viewmodel I would instantiate a new model item class, wrap it in the viewmodel item class and then add the model item class to it's list and the wrapped class in the viewmodel collection to keep them in sync. Thanks for the help.
|
# ? Mar 21, 2015 10:25 |
|
Mr Shiny Pants posted:So I wrap my model properties within my viewmodel properties right? Yes exactly. Sort of sounds like you are mixing two ideas. In the example mentioned I would just add the email addy to the model's list and then trigger OnPropertyChanged on my ObservableCollection to show that. You can certainly bind to an ObservableCollection of viewModels (I think that's what you are getting at) instead of just returning the models List, but that would be if you had a reason for each item to be it's own viewModel. In that case, you could simply add a new viewModel to the ObservableCollection of viewModels. That viewModel would instantiate a new model in which it's own properties would provide access to it's model.
|
# ? Mar 21, 2015 17:42 |
|
GoodCleanFun posted:Yes exactly. I don't have observable collections in my model. Just a list. So now I have some logic in my viewmodel that puts a new item in my model list and puts the appropriate view model in an observable collection. This way they are in sync, my remove methods are a bit more work but it seems ok.
|
# ? Mar 21, 2015 20:41 |
|
epalm posted:Apparently once in a while Azure Websites inexplicably drop connections to Azure SQL Servers. This happens often enough that they've written a BandaidThisHugeProblem class (cleverly named SqlAzureExecutionStrategy) to retry the connection if it drops. All that seems such a bad idea. But I think your question "why is it hard to write a reasonably robust application" is misguided. Every single distributed interaction has three possibilities: [1] it might succeed and you know it (e.g. 200) [2] it might fail and you know it (e.g. 404) [3] it might succeed/fail but you don't know which (e.g. ConnectionLost or Timeout) All that an automatic-retry strategy does is alter the probability distribution of the three outcomes (making the first two slightly more likely and the third slightly less likely) at the cost of increasing the latency of [3], and also increasing your code complexity. Is it worth doing automatic retry? -- only if you have statistical evidence that your retry strategy will significantly reduce the probability of [3], enough so that the increased latency of [3] doesn't matter, and only if you have statistical evidence that the extra code complexity is worth it because it noticeably improves user satisfaction. But make no mistake: you still have to handle case [3]. I too have observed transient Azure SQL errors but only very rarely, not enough to make any solid statistical summary out of it. I've searched high and low for solid statistics on failure rates in Azure SQL databases but without success. In the absence of such evidence, I think it's just a bad idea to throw more code into your application (code that will almost never be tested! and code that handles already-rare cases!) Especially since it's an already-rare case, and your time is better spent adding other more noticeable user value. I think the answer's straightforward. If you have a user-facing website or client app that connects to the AzureSQL database, then your website/app should fail fast and give the user the opportunity to retry. That's because users end up far wiser than our code about retry strategies, and they always appreciate "fail-fast". And if you have a non-user-facing batch processing job, then just schedule it to be run again at the next scheduled time. I think that "automatic retry" is an anti-pattern. ljw1004 fucked around with this message at 13:37 on Mar 22, 2015 |
# ? Mar 22, 2015 13:34 |
|
I'm trying to create a tray icon for my little home brewed application. Based on the code I have below, can anyone help me with the following- 1) The icon will stay after the program has quit until you hover over it. This can create multiple "ghost" icons. How do I prevent this? 2) A lot of the time click on the menu item, even though its clearly highlighted, won't do anything at all. What's the deal with that? 3) Each time the context menu opens up a taskbar icon is opened as well. How do I stop this?!?! 4) I have code that closes the context window after the mouse hovers away from it, but I'd rather it be so the user has to click to make it close. I can't find any examples that have worked for me thus far. Here's the code- code:
TheEffect fucked around with this message at 07:43 on Mar 23, 2015 |
# ? Mar 23, 2015 07:41 |
|
Well, the retard of the day award goes to me. I was having problems getting my combobox to bind to a field in my model. Everything I tried the stupid SelectedItem would not show the value of my model. Turns out the default width of the control was larger than the space I had given it in my template, so the value was there but it got cut off. This took me a couple of hours to figure out............... Didn't help that the values are only two characters.......
|
# ? Mar 23, 2015 09:57 |
|
I am having an infuriating WPF problem: a custom UserControl I've made is failing to load with "The component [my component] does not have a resource identified by the URI [URI which definitely points to a real thing]." How do I know the URI is good? Because it works sometimes, just not all the time (as in, I can restart the application and it will work. Maybe.) But it's been getting worse, and now it basically never works. What the hell is going on? Googling this suggests restarting Visual Studio (didn't help), manually cleaning my project (used to help, now doesn't), switching off the client profile (never targeted it), and manually creating objects in the code behind (not really applicable here, I think). Apparently some people only have this problem at design time, but it's becoming a real run-time problem for me. raminasi fucked around with this message at 15:52 on Mar 23, 2015 |
# ? Mar 23, 2015 15:15 |
|
GrumpyDoctor posted:I am having an infuriating WPF problem: a custom UserControl I've made is failing to load with "The component [my component] does not have a resource identified by the URI" Can you create a test project that exhibits the problem? When WPF does things that are totally weird, I start with a fresh project and include ONLY the necessary parts. At best, I can narrow down exactly what's causing the strange behavior (and start to ask why). As worst, I have a sample solution I can show folks here / StackOverflow / Microsoft.
|
# ? Mar 23, 2015 15:38 |
|
epalm posted:Can you create a test project that exhibits the problem? The problem isn't consistent. Sometimes it happens, and sometimes it doesn't. It's just been getting more and more frequent. e: I have successfully solved my problem, for the moment, by commenting out the body of the custom control, rebuilding, uncommenting it, and rebuilding again. The Team Explorer reports no differences between the "before" and "after" code. raminasi fucked around with this message at 16:20 on Mar 23, 2015 |
# ? Mar 23, 2015 15:43 |
|
So my client has a solution with 121 projects in it, and through branching and merging the .sln file has developed some issues. Are there any tools out there that will analyze a .sln file and find problems? The specific error we're getting is "Error parsing the nested project section in solution file."
|
# ? Mar 23, 2015 15:59 |
|
TheEffect posted:1) The icon will stay after the program has quit until you hover over it. This can create multiple "ghost" icons. How do I prevent this? Remember to call Dispose on the icon when your application is exiting.
|
# ? Mar 23, 2015 16:45 |
|
I know this might be pure convention, is it proper in .NET MVC and in MVC design in general to have a view that just consists of other views? I have 3 partials views which I want to display on a single page, do I make a "wrapper" view and just call each of the partials, or do I promote on of the partials to a full view. On one hand is kinda seems like useless junk but on the other I can see it being nice.
|
# ? Mar 23, 2015 16:58 |
|
Dietrich posted:So my client has a solution with 121 projects in it, and through branching and merging the .sln file has developed some issues. Are there any tools out there that will analyze a .sln file and find problems? I'm not aware of specific tools but one place to start might be trying to msbuild the solution file in verbose mode and see what it trips on. Looking at the sln file might also work -- they aren't that wacky, sometimes merge artifacts are very obvious. Blame can also help.
|
# ? Mar 23, 2015 18:12 |
|
ljw1004 posted:I too have observed transient Azure SQL errors but only very rarely, not enough to make any solid statistical summary out of it. I've searched high and low for solid statistics on failure rates in Azure SQL databases but without success. In the absence of such evidence, I think it's just a bad idea to throw more code into your application (code that will almost never be tested! and code that handles already-rare cases!) Especially since it's an already-rare case, and your time is better spent adding other more noticeable user value. Well it's happened March 19th at 12:19 EST March 23rd at 19:25 EST March 23rd at 22:58 EST March 24th at 10:46 EST The EntityException stacktrace looks like this: http://pastebin.com/raw.php?i=ZX3M5dwz My site is still in beta, no real traffic yet. Less than 500 requests per day. Doesn't seem rare at all Edit: Sorry if it seems like I'm complaining to you personally, ljw1004. I know it's not your fault I think I'm just mad that this is an issue I have to deal with at all. I know everything is virtualized but both site and database are physically in the same datacenter (East US). I'm coming from eApps and Linode and DigitalOcean and the application code served through the web server dropping the connection to a database in the same datacenter is just Not A Thing I've had to deal with before. I guess I'll go ahead and apply my own bandaid overtop Microsoft's bandaid Bognar posted:We saw that we were doing a bunch of stuff to get Azure happy with transactions, so we ended up making our own wrapper around Transaction that implements IDisposable. That would probably also work for you, and you could set SuspendExecutionStrategy = true in the constructor and false in the Dispose implementation. Mind if I steal this from you? Or, if I do it myself by setting SuspendExecutionStrategy to true/false in the constructor/dispose, is that all or is there more to it that you've stumbled across? epswing fucked around with this message at 15:55 on Mar 24, 2015 |
# ? Mar 24, 2015 01:54 |
|
I read the OP, I see Skeet and Richter recommended for books. I'm used to Java and C++, with somewhere between an undergrad sophomore and junior level of understanding. So I don't need to have the difference between a parent class and an interface explained to me. But I still need something aimed at a relatively low level. Which of the two would you recommend (or others)?
|
# ? Mar 24, 2015 07:39 |
|
|
# ? Jun 1, 2024 09:38 |
|
22 Eargesplitten posted:I read the OP, I see Skeet and Richter recommended for books. I'm used to Java and C++, with somewhere between an undergrad sophomore and junior level of understanding. So I don't need to have the difference between a parent class and an interface explained to me. But I still need something aimed at a relatively low level. Which of the two would you recommend (or others)? I liked this: http://www.amazon.com/Learning-C-3-0-Jesse-Liberty/dp/0596521065 It is old now, but I found it pretty good. If you can get it cheap, why not. It does not have the async stuff, but for C# itself can still be relevant. E: Seems like there is a version 4 also. Might want to check that.
|
# ? Mar 24, 2015 09:18 |