|
You could create a notification property like IsBusy and make the setter private. I do this because I usually want to disable more than one control/button. Edit: Can't do code on my phone worth a drat. Basically make a property IsBusy and hook it up to OnNotifyPropChanged. Set it during any of your background tasks and change your RelayCommand enabled code to just check that property. crashdome fucked around with this message at 23:27 on Oct 16, 2015 |
# ? Oct 16, 2015 23:24 |
|
|
# ? Jun 1, 2024 15:00 |
|
You should fire ICommand.CanExecuteChanged (your RelayCommand may or may not have an API to fire it)
|
# ? Oct 16, 2015 23:46 |
|
crashdome posted:You could create a notification property like IsBusy and make the setter private. I do this because I usually want to disable more than one control/button. Oh yeah, that'd work, thanks. I was trying to skip the extra property by monitoring the Task directly. Doesn't work so well when properties of Task don't trigger INPC... This is what I get for trying to actually be productive on a Friday
|
# ? Oct 16, 2015 23:59 |
|
I'm having an issue with a C++ library in a UWP. In VLC for Windows Store, we have a wrapper library in C++ that interacts with LibVLC (for handling video, audio, all that jazz). Right now there is a Windows 8 and a Windows Phone 8.1 version, with a shared base, each assigned to the correct universal project. In our UWP solution currently, the desktop X86 version points to the Windows 8.1 x86 version, the phone pointing to the Windows Phone 8.1 ARM version. Others on the team think that just recompiling these existing libraries should just work on UWP. However, if I try that, I get this:code:
|
# ? Oct 19, 2015 03:23 |
What would be the best way to have a .net 3.5 console app communicate with a .net 4.0 console app?
|
|
# ? Oct 19, 2015 16:25 |
|
Manslaughter posted:What would be the best way to have a .net 3.5 console app communicate with a .net 4.0 console app? Do they run on the same machine? PowerShell may be an option.
|
# ? Oct 19, 2015 18:29 |
|
Drastic Actions posted:I'm having an issue with a C++ library in a UWP. In VLC for Windows Store, we have a wrapper library in C++ that interacts with LibVLC (for handling video, audio, all that jazz). Right now there is a Windows 8 and a Windows Phone 8.1 version, with a shared base, each assigned to the correct universal project. In our UWP solution currently, the desktop X86 version points to the Windows 8.1 x86 version, the phone pointing to the Windows Phone 8.1 ARM version. Others on the team think that just recompiling these existing libraries should just work on UWP. However, if I try that, I get this: Drastic, I find your post confusing, so I'm going to spell out the basics. (1) Understand that the "Win10 Desktop" operating system has a set of WinRT APIs. This set of APIs is equal to "UWP + DesktopExtensionSDK". Likewise, the "Win10 Mobile" operating system has a set of APIs that is equal to "UWP + MobileExtensionSDK". (2) If you have a UWP DLL, e.g. a class library, that invokes APIs just from UWP then it is guaranteed to be able to run fine on both. But if it invokes APIs that are only found in the Desktop extension SDK then, if you try to run it on Mobile, it will crash at runtime when it attempts to invoke that API or create that class. (3) If you have a .NET dll from Win8.1 or WP8.1, then it will load and run fine on Win10, so long as only invokes APIs that are present on the operating system it's running on. (4) The set of Win8.1 WinRT APIs is a subset of "UWP + DesktopExtensionSDK". The set of WP8.1 APIs is a subset of "UWP + MobileExtensionSDK". Therefore, if you have an 8.1 .NET dll, then it is guaranteed to run fine on either Win10Desktop or Win10Mobile depending on whether it was a Win8.1 or WP8.1 dll. It might run okay on the other Win10 OS, depending on which APIs it happens to invoke. (5) For C++ the story is different with respect to part (3). A C++ dll that was compiled for 8.1 has the wrong set of lib references or APIsets or something like that in its binary. Therefore the C++ dll must be recompiled in order to work in UWP apps. As to whether it can easily be recompiled or not, that depends on which APIs it happens to use, as per (4). I found it hard to understand what you're doing. You said that if you try just recompiling your native source code then you get a BadImageFormatException. But you say "there would be issues anyway because they use APIs that are not in UWP". * Did you or did you not recompile your source code as a UWP project? If you did, then how did you get around the fact that you used APIs that aren't in UWP? (as per my point (1), you should have been able to recompile it after doing work to incorporate extension SDKs or APISets or whatever the C++ technology is, and you should have been disciplined to protect the Mobile-specific or Desktop-specific code with adaptive lightup checks). * BadImageFormatException sounds like you in fact didn't recompile your native dll, and you just tried to make your UWP app reference that 8.1 native dll. In this case your UWP app would compile fine, but when you tried to load it, it would try to load the native DLL, and would try to IMPLIB all the imports required by that native DLL. And so it would fail at loadtime saying that there was something wrong with the DLL image.
|
# ? Oct 19, 2015 19:00 |
RICHUNCLEPENNYBAGS posted:Do they run on the same machine? PowerShell may be an option. I ended up just publishing a web site with a .svc
|
|
# ? Oct 19, 2015 19:03 |
|
I'm not shocked what I said made no sense, because I don't really understand it myself. Originally, we had a Windows 8.1 and a Windows Phone 8.1 C++ dll project. They were referenced to our UWP solution. The other VLC developers think that we can just use our Windows 8.1 project in the UWP, and that the only error I'm getting is that it's not compiling the right DLL for the project. They assumed that the same Windows 8.1 DLL would work in the UWP solution too. It won't. So I figured I would make a Universal Library which would work. First I looked into the Windows 8.1 project. There are two files, MMDeviceLocator.cpp and Thumbnailer.cpp which have API calls that can't be used in UWP. In MMDeviceLocator, there is this code:
In Thumbnailer: code:
So I made my new Universal project, change the calls from above to ones that should work, and reference that in my UWP app. That, I think, should get me the native DLL I'm looking for. And when I did... I still got the same BadImageFormatException. I've tried cleaning the solution, making sure that the only DLLs I'm making are the Universal ones. But nothing. So I'm not sure which element of this is failing, and what I'm doing wrong. EDIT: As a further test, I just build the library project as x86, and referenced the winmd files directly in my UWP project, building that under x86 as well. Still get the same BadImageFormatException . Drastic Actions fucked around with this message at 21:19 on Oct 19, 2015 |
# ? Oct 19, 2015 20:45 |
|
Another stupid WPF question. I have an old UserControl called ImageButton (probably every single WPF project has one of these): XML code:
XML code:
Focusable="True/False" IsTabStop="True/False" KeyboardNavigation.IsTabStop="True/False" KeyboardNavigation.TabNavigation="None/Continue" Adding KeyboardNavigation.TabNavigation="None" to the UserControl tag does in fact cause a tab to skip the button, but this affects all ImageButtons and no amount of tweaking to the call site will allow a particular ImageButton to be a tab stop. Any advice? The request made by the client is painfully simple ("when I tab, I want to skip this button"), which makes this all the more infuriating.
|
# ? Oct 19, 2015 21:17 |
|
What happens if you set the property via a style setter somewhere?
|
# ? Oct 19, 2015 22:14 |
|
Has anybody read (an earlier edition of) Expert F# and has an opinion on it?
|
# ? Oct 20, 2015 01:45 |
|
Random IIS question: Is there any reason I would want to set the X-Frame-Options header (for clickjacking) at the site level as opposed for the entire server? I keep getting pushback from the sysadmins about setting this at the server level. (Part of the problem is that they don't know how to set headers for the entire server, but that's another issue that can be easily solved by point them at https://technet.microsoft.com/en-us/library/cc753133(v=ws.10).aspx)
|
# ? Oct 20, 2015 14:41 |
|
It rather depends on the overall devops workflow and how such policies apply. On my deployments, each product/service is completely independent and I would be aghast at hearing of some server-global configuration being applied to my service. The only configuration I want to see applied is that which my dev team and my operations team explicitly and intentionally configure, and such decisions are always done on a per-site basis, as each site is an independent product/service. Overall, server-level configuration is something I have never seen, except on some forums and blogs where it has always smelled to me. But, to play the devil's advocate, I can imagine it making sense if you have e.g. 200 customer blog websites on one server that you manage and you want to enforce proper security practices on all of them. What exactly is your scenario about? Why do you want to apply this header? To what sort of sites?
|
# ? Oct 20, 2015 15:23 |
|
EssOEss posted:It rather depends on the overall devops workflow and how such policies apply. On my deployments, each product/service is completely independent and I would be aghast at hearing of some server-global configuration being applied to my service. The only configuration I want to see applied is that which my dev team and my operations team explicitly and intentionally configure, and such decisions are always done on a per-site basis, as each site is an independent product/service. This header needs to be applied to address issues that come up in Acunetix PCI compliance scans. Some of these sites are basically marketing sites, but some are B2B management portals for the products/services we offer. There are also a small handful of consumer-facing sites for managing their end of things. Probably about 15-20 sites total that this needs to be done for across 5 or 6 server environements (some load-balanced, some not).
|
# ? Oct 20, 2015 15:33 |
|
GrumpyDoctor posted:What happens if you set the property via a style setter somewhere? Added this to my UserControl: C# code:
XML code:
epswing fucked around with this message at 15:58 on Oct 20, 2015 |
# ? Oct 20, 2015 15:53 |
|
This is less a technical question, but now that Windows Runtime stuff can be windowed is that the way that desktop GUI stuff is going to go in the future? Are they going to invest in WPF and maybe make the XAML less unwieldy? It just feels to me like this is one area where C#/.NET/the MS universe has been weirdly stagnant.
|
# ? Oct 20, 2015 16:52 |
|
RICHUNCLEPENNYBAGS posted:This is less a technical question, but now that Windows Runtime stuff can be windowed is that the way that desktop GUI stuff is going to go in the future? Are they going to invest in WPF and maybe make the XAML less unwieldy? It just feels to me like this is one area where C#/.NET/the MS universe has been weirdly stagnant. Perhaps it might be interesting to turn this question on its head: what needs do you have that are not being met by UWP? I wonder how big the needs for non-UWP apps will be in 5 years (in the context of something that actually has a GUI - obviously services and such are relevant). Finster Dexter posted:This header needs to be applied to address issues that come up in Acunetix PCI compliance scans. Some of these sites are basically marketing sites, but some are B2B management portals for the products/services we offer. There are also a small handful of consumer-facing sites for managing their end of things. Probably about 15-20 sites total that this needs to be done for across 5 or 6 server environements (some load-balanced, some not). I can't really give more input regarding your actual question but having gone through implementing PCI compliance in the recent past, I can share some advice on the actual PCI aspect. The main thing to understand here is that being PCI DSS compliant is about following a process, it is not about builing "secure" software, for whatever definition of secure. This means that as long as warnings such as this one are properly understood, the impact documented and the risk taken into account, all is well. To reiterate, PCI compliance is about having a process that can detect and, if the stakeholders consider it relevant, help prevent vulnerabilities. However, there is no requirement to always follow every secure coding guideline in the world. If clickjacking is considered an acceptable risk by the product owner, having non-clickjacking-proof software is just fine as far as PCI goes. I say this because it seems to be a common fallacy to believe that PCI means nailing down every leak and closing all vulnerabilities but this is just not the case. Obviously, many PCI consultants and auditors like to give that sort of impression since it gives opportunities for good upselling of various services that might otherwise not really be needed. Thankfully, our auditors were a reasonable bunch who helped us understand the real story and did not try to give us the runaround. EssOEss fucked around with this message at 17:18 on Oct 20, 2015 |
# ? Oct 20, 2015 17:08 |
|
epalm posted:Added this to my UserControl: Oh, I was thinking of doing it entirely in the XAML but I'm glad you got it working
|
# ? Oct 20, 2015 17:15 |
|
EssOEss posted:Perhaps it might be interesting to turn this question on its head: what needs do you have that are not being met by UWP? I wonder how big the needs for non-UWP apps will be in 5 years (in the context of something that actually has a GUI - obviously services and such are relevant). Well, I don't have any, but to be honest GUI programming is kind of boring to me so I'd rather not invest a lot of time learning a new way of doing it unless it's got legs. The only real desktop GUI stuff I've done is Windows Forms (which kind of blows but hey).
|
# ? Oct 20, 2015 17:33 |
|
GrumpyDoctor posted:Oh, I was thinking of doing it entirely in the XAML but I'm glad you got it working Oh, ha, a Style setter. Gotcha The UserControl C# property seems to do the trick, so I'll stick to that until it breaks :P
|
# ? Oct 20, 2015 20:48 |
|
I'm looking to move an application from a basic desktop executable to a Windows Universal App for Windows 10, and so far things have been going well; hamburger buttons and working in XAML is a change of pace from C# but not bad. I've run into a snag however: The point of the application is to change the desktop background image, which I was previously doing using the registry. However, the Windows Universal App doesn't seem to allow that; if I add " using Microsoft.Win32; " I'm still unable to reference the RegistryKey class. I've read a few snippets about Universal Apps being self-contained in that regard, does that mean they can't access the registry period? If so, does anyone know off the top of their head if they exposed access to the desktop background image settings anywhere else, or could I round-about it calling something like a command prompt script or powershell script?
|
# ? Oct 20, 2015 23:29 |
|
Mo_Steel posted:I'm looking to move an application from a basic desktop executable to a Windows Universal App for Windows 10, and so far things have been going well; hamburger buttons and working in XAML is a change of pace from C# but not bad. I've run into a snag however: You can't use Win32 in a UWP. You can't call the command line or powershell either. You should be able to call "Windows.System.UserProfile.UserProfilePersonalizationSettings.Current.TrySetWallpaperImageAsync(StorageFile file)". C# code:
|
# ? Oct 21, 2015 00:33 |
|
Drastic Actions posted:You can't use Win32 in a UWP. You can't call the command line or powershell either. Ahh, that makes sense. For a little more clarity, I put together some code a while pack that goes and retrieves the Astronomy Picture of the Day and makes it the desktop each day when the user first signs in. I was hoping to move it up to a Universal App so people could get it off the app store and the like and as an excuse to toy around with UWP some, but it sounds like it'll be a total rework if it even functions. I've got the old, perfectly fine version out on a repo here and aside from when they post videos it works pretty great. I was thinking of moving to PowerShell to handle making scheduled tasks at "install" rather than the task scheduler c# wrapper I've been using.
|
# ? Oct 21, 2015 01:57 |
|
There is apparently something called Project Centennial which enables oldschool non-UWP apps to be distributed via the Store, so you might not really need to make it an UWP app. It appears to still be unreleased even as a preview, though. Possibly even vaporware?
|
# ? Oct 21, 2015 05:23 |
|
EssOEss posted:There is apparently something called Project Centennial which enables oldschool non-UWP apps to be distributed via the Store, so you might not really need to make it an UWP app. It appears to still be unreleased even as a preview, though. Possibly even vaporware? I'd heard closed beta maybe next year, and figured I'd rather try it myself and take a look at the new stuff in the platform.
|
# ? Oct 21, 2015 05:37 |
|
Mo_Steel posted:Ahh, that makes sense. Updated my Github page. You can download images from there to apps local storage and it works just fine. You should be able to make a background task and schedule it every day to auto update too. Just as long as you're downloading the image to local storage, it should work.
|
# ? Oct 21, 2015 14:05 |
|
EssOEss posted:Perhaps it might be interesting to turn this question on its head: what needs do you have that are not being met by UWP? I wonder how big the needs for non-UWP apps will be in 5 years (in the context of something that actually has a GUI - obviously services and such are relevant). Wise words. I think on this particular issue, the powers that be have decided NOT to risk except this, but your arguments about server-wide configuration being smelly and maybe an anti-pattern make me think I should just implement this on each site and call it good. e: next problem on the list... I see a lot of conflicting reports for how SERVER_NAME is populated in IIS. I'm thinking of replacing HTTP_HOST with SERVER_NAME in some web.config rewrite rules in order to mitigate Host header attacks. But it seems like SERVER_NAME is dependent on doing a reverse DNS lookup for the server? Or some people think it just uses HTTP_HOST anyway? Or there is some way to set "host headers" in IIS to configure the value of SERVER_NAME? Anyone have experience with this? Finster Dexter fucked around with this message at 15:36 on Oct 21, 2015 |
# ? Oct 21, 2015 15:07 |
|
Drastic Actions posted:
This is some simpleproxybeanfactoryfactor poo poo. That is one hell of a path.
|
# ? Oct 21, 2015 16:54 |
|
LeftistMuslimObama posted:
You don't have to use the whole thing, it was just to make it easer to explain where the namespace is.
|
# ? Oct 21, 2015 17:09 |
|
Drastic Actions posted:You don't have to use the whole thing, it was just to make it easer to explain where the namespace is. I haven't done much UWP, but how likely is someone to have a reference to Windows.System.UserProfile.UserProfilePersonalizationSettings.Current just hanging out in their program? I just love precariously long paths like that. \/\/\/ edit: Yeah, that makes sense. The MUMPSorceress fucked around with this message at 18:08 on Oct 21, 2015 |
# ? Oct 21, 2015 17:59 |
|
Well, in practice you probably import Windows.System.UserProfile and then say UserProfilePersonalizationSettings.Current.
|
# ? Oct 21, 2015 18:05 |
|
EssOEss posted:Perhaps it might be interesting to turn this question on its head: what needs do you have that are not being met by UWP? - run on older windows versions - access the filesystem - connect to sql databases - exes/installers without going through the windows store there are some smaller details but it doesn't seem worth investigating workarounds for other stuff unless those dealbreakers are resolved.
|
# ? Oct 21, 2015 20:05 |
|
Drastic Actions posted:Updated my Github page. You can download images from there to apps local storage and it works just fine. You should be able to make a background task and schedule it every day to auto update too. Just as long as you're downloading the image to local storage, it should work. I'll take another look, thanks.
|
# ? Oct 22, 2015 06:00 |
|
Does anyone have a link or an explanation of how a viewmodel-first MVVM solution is started in practical terms? Like, I get the idea, but haven't a clue what/where the code or XAML or linkages look like or are.
|
# ? Oct 22, 2015 21:18 |
|
I typically start ViewModel first but, I don't know if I am following a best practice or not. I just decided it was more comfortable for me to do it this way. I usually start with an Interface for my VMs so I can create a design-time ViewModel with mock values for UI design. I then create a stub ViewModel for production Wire both in to the Service Locator Create a new View and add the binding for the Service Locator ViewModel path Then I start designing the UI which dictates if I need to change the ViewModel Interface at all When I'm happy with the View, I start filling in the real ViewModel with code for the services/models. Having a design-time ViewModel first means I can tweak the View until I know it is designed to my preference. It also is a good way to get screenshots if I need to ask the client usability questions before any actual code is written. Edit: I use MVVM Light so most of the boilerplate is already there when I start. I have a few of my own classes I may port in but, generally I follow the structure it gives me. I also work on more than one ViewModel at a time. When I do, the design VMs are filled with mock data and the real VMs are filled with TODO or Not Implemented Exceptions so I don't forget to write the actual code in my methods. Unit tests are placed against the real VMs only and usually I only test methods or Properties that do service calls. These also helps let me know if I forgot anything. crashdome fucked around with this message at 22:50 on Oct 22, 2015 |
# ? Oct 22, 2015 22:45 |
|
I will try to give you a real example based on an UWP app that I recently created. If there is some backend business logic (downloading feeds or whatnot), I build that logic first and use automated tests to verify that it works. This becomes part of the model. Only really feasible if you have some strict requirements that you know will not change based on the view, or if you have enough experience to be able to predict exactly what the view will need from the model. Everything in the app serves the view. Any special model-building aside, I start from the view first. I create the various pages of the application as Page objects and fill in placeholder XAML that has the right elements but dummy data (hardcoded) and very rough styling. Something like this: code:
code:
code:
code:
The viewmodel serves the view, so what goes in there is 100% dictated by the view. If I have a bottom pane that may or may not be visible, I make a BottomPaneVisibility property of type Visibility. code:
code:
For real testing, you need to run the app - the design view is only suitable as a very rough guideline. During initial stages, I just set whatever thing I am working on as the root page shown on startup. Later, it can get more annoying once the app fills out more with functionality. Hmmm what else matters... aha, associating view and viewmodel and model. The view is always provided the viewmodel on "startup". Specifically, for Pages, the viewmodel to use is the navigation parameter. So in my App.xaml.cs I have this in the OnLaunched method: code:
code:
Viewmodels are provided any Model references in their constructor parameters. For larger apps, I use a dependency injection container to automatically wire stuff up via this constructor. For smaller apps, I just do it manually. Okay but what calls the constructor? Other viewmodel objects! Say, if I want to navigate from MainPage to PlaybackPage when some button is pressed, I have a command in whatever viewmodel matches up with that button: code:
On the topic of events, make sure that your view always detaches from the viewmodel and your viewmodel always detaches the from model! Keeping event handlers hooked up when the views and viewmodels are not needed is a very easy way to end up with resource leaks! Example of viewmodel event registration and de-registration in the view: code:
code:
I think this covers the basics... feel free to ask if you have any questions related to this! Obviously, this is just my interpretation of MVVM and there are many others. However, I stand by it as a very practical one and I have been using it for around 5 years now, from the good old days of Silverlight 2. Here is an example GitHub repository with a partial sample of the app in question (it's an internal development workbench type of app for a library): https://github.com/sandersaares/mvvm-example EssOEss fucked around with this message at 09:06 on Oct 23, 2015 |
# ? Oct 23, 2015 08:57 |
|
That seems like a lot of code-behind for an MVVM app. If you had a design VM you could forego a lot of the hard-coded text and having a Service Locator that swaps between design-time and run-time automatically would mean far less work to hunt down that manually entered stuff later. I agree that a View dictates a lot of VM work but, it's pretty trivial to write up a VM Interface and change it as the view changes design. It's also true you don't need a framework but, these lighter ones really cut down the need to boilerplate things like weak events and ViewModel base classes. I'll see if I can write up a simple step by step that I use and post it here in a moment. Edit: This example uses an Interface for the underlying service of the VM and is based on the MVVM Light samples. I've modified this process a bit for myself because I hated having a unique "Service" for each VM but, the majority of principles are the same. Ignore the methods and such as they may not pertain to you or you might want something different based on any models or base classes you develop on your own. Start with an Interface with all the items your viewmodel might need C# code:
Note most of the methods don't need to function but need to be implemented to not throw any errors C# code:
Also, I'll skip posting the Unit tests. Basically I unit test some of the methods that interact with my Data/Model layer and any that I know I need to fill in and remove the NotImplementedExceptions. Create the actual VM C# code:
C# code:
C# code:
Unit Tests should point anything you forgot in run-time service (NotImplementedException) as should any TODO comments if you follow that practice. It's different than EssOEss's method but then, the MVVM Light framework eliminates much of the boilerplate he wrote. I also like that the ServiceLocator eliminates Context binding in the View's code behind for design mode. You don't need MVVM Light for this practice but, you'd need to do all the boilerplate MVVM stuff ahead of time like the base ViewModel class and any Navigation services or such. I hate code-behind in my View and I have 99.9% code-behind free views. The only exception is some custom code-behind for reducing some boilerplate code for some specific Views I use and consists of usually a single line of code in the View constructor. crashdome fucked around with this message at 20:50 on Oct 23, 2015 |
# ? Oct 23, 2015 19:40 |
|
I am really put off by the service locator/view model locator/big ball of singletons pattern. Am I crazy?
|
# ? Oct 25, 2015 03:20 |
|
|
# ? Jun 1, 2024 15:00 |
|
fleshweasel posted:I am really put off by the service locator/view model locator/big ball of singletons pattern. Am I crazy? I'm with you.
|
# ? Oct 25, 2015 06:36 |