This post applies to Windows Universal Apps specifically. These techniques probably won’t work with WPF or Windows 8/8.1 Apps because the XAML hierarchy and namespaces are different.
The title is certainly a mouthful, but stick with me to understand where this scenario can be useful.
Let’s say you want to re-use a ListView without copy and pasting everything about it wherever you need it. Simple enough, right? Just put it in a UserControl! Not so fast. What if you want to define the ListView’s ItemsSource from one level above the UserControl? It gets a little more complicated. This is especially true if you want to take advantage of a VisualStateManager with the ListView’s ItemTemplate.
For example, I had a UserControl which allowed users to scroll left/right on a ListView by clicking buttons left/right instead of using a scrollbar. I wanted to share this ListView in multiple places, but didn’t want to restrict the UserControl to a single ItemsSource by hard coding it in the UserControl itself. I wanted to “pass in” the ItemsSource and DataTemplate to define the layout of the items from one level above the UserControl. Additionally, I wanted the layout to change based on the width of the screen to work with phones, tablets, and wide layouts.
So here’s what I did after a few hours of struggling through wildly varying documentation across WPF, Windows 8/8.1, and Windows Universal Apps.
Creating the DataTemplate UserControl
We first need to define the lowest level of the chain to determine what and how the data will be displayed in each data bound ListViewItem.… Continue reading
I’ve written in the past about how to setup WordPress on an Azure App Service and about connecting that WordPress instance to MySQL in an Azure VM. While these articles do contain some useful information about setting up WordPress and its interaction with Azure services, I’ve come to the conclusion that WordPress simply doesn’t function as nicely when hosted on IIS.
For about 1-2 years, I hosted several WordPress blogs in Azure App Services which connected to MySQL instances on an Azure VM (exactly as described in my articles above). I struggled endlessly with strange plugin issues and constant timeouts when attempting to connect to MySQL. For example:
- Certain caching plugins complained that certain settings could not be applied due to IIS
- WordPress.com and JetPack integration sometimes didn’t detect plugin and WordPress updates properly
- When attempting to update plugins from WordPress.com or JetPack, it would simply fail with no error messages
- Random and intermittent “Database connection” failures would occur even though I could guarantee the username/password/connection information was correct (especially since connections would succeed and then fail 30 seconds later)
I tried debugging these issues for months including monitoring incoming traffic on the VM to diagnose MySQL connection timeouts but was ultimately unsuccessful in determining a solution. Actually, that’s not entirely accurate. I did come up with a solution. I stopped using WordPress on Azure App Services.
So what to use then? I decided on using my existing VM to host the classic LAMP stack. It was already running Linux and MySQL, so I just had to add Apache and PHP.… Continue reading
I’ve spent some recent weeks building a cool new web site which exposes a lot of Dota 2 game data which may not be easily accessible to most players. You might be thinking, but I already use DotaBuff for all my Dota 2 needs! DotaBuff is great, but it doesn’t cover everything.
For starters, the new Dota Database that I’ve created is useful to see some of the finer details regarding heroes, hero abilities, items, item abilities, cosmetic items for purchase in the store, and more. This includes details like spell and ability behaviors, which shops you can purchase an in game item, hero level progressions, cosmetic item sets, and even pro player autographs. The information for these specifics comes directly from the game files and the Valve provided Dota 2 web APIs.
Live League Game Listing
This page will give you a paged listing of all currently live league games. Some games will display blank data when still in the hero picks/bans phase. Each listing shows the league, the team names, elapsed times, spectator counts, series scores, team scores, player scores, player picks, team worth, and team XP. Click in to the listing to see all the live updated details for the match.
See it in action
Live League Game Details
When you click in to a live league game, you’ll see a page full of information about that game. Every 20 seconds, the page will refresh and show you the latest updates about the match. All data is provided by Valve through its Dota 2 league web API.… Continue reading
Azure Key Vault has been generally available in certain regions since June 2015. You can’t use the Azure Portal to work with the key vault yet, so you have to drop down into Azure Powershell and run a few commands. It’s a little confusing to get started since development is ongoing and Azure Powershell itself changes frequently.
Here’s how I have been achieving some simple Azure Key Vault commands via Azure Powershell. I’m using Azure Powershell version 0.9.8, so keep that in mind if you’re comparing these commands to the Getting Started guide linked previously in this article.
Check Your Azure Powershell Version (optional)
If you don’t know what version of Azure Powershell you’re using, try this:
(Get-Module azure -ListAvailable).Version
Switch to AzureResourceManager Mode if Necessary (optional)
Since you’re using version 0.9.8 like me, you need to switch into Azure Resource Manager mode.
Login to Azure
Login to your Azure account and enter your credentials in the popup window. It seems kind of odd that it wouldn’t just make you login via Powershell parameters.
Create a Resource Group (optional)
You need an Azure Resource Group to add the Azure Key Vault to. If you don’t have one already, create it now. If you already have one, skip this step.
New-AzureResourceGroup -Name <ResourceGroupName> -Location <ResourceGroupLocation>
Create a Key Vault
Now create the Azure Key Vault.… Continue reading
All of the following commands should be executed in the folder containing the project from which you want to create a package.
nuget spec – Create a .nuspec file which contains meta-data about the package such as author, description, and title. You will need to edit some of the values in this file when you first create it.
nuget pack <.csproj file name> -Prop Configuration=Release – Create a .nupkg file containing the compiled contents of the project specified in the first parameter. Optionally target a specific configuration.
nuget push <.nupkg file name> – Push the NuGet package up to your NuGet.org account.
More complete documentation here.… Continue reading
People these days tend to buy a lot of gadgets and electronics. Between our smart phones, televisions, cars, computers, tablets, and e-readers, the expense can add up. Many times, we overlook the importance of cataloging everything that we own for various reasons.
First, it keeps us honest. Do we really need another iPhone if we just bought one a year ago? Probably not. Your stash in our service will remind you of when you purchased something (provided you are honest).
Second, theft and loss are real things. We like to pretend that bad things will never happen to our expensive stuff, but it can and probably will. A phone that costs $600 is not something to take lightly, especially if your daily activities require a lot of movement. Documenting the condition of your belongings, when you purchased them, the purchase receipts, and any other details about them can help with police reports and your home or rental insurance.
Third, it’s quite convenient and safe to store your information in online stash. You can pull up your stash on any device that you own immediately. You don’t have to go searching through paper receipts, pulling out the TV to find out what model you have, or go digging through your file cabinets. Everything in your stash is ready for you and secured with multiple levels of security.
Get started for free at https://www.saferstash.com.… Continue reading
I am what I would consider tech-savvy. I tend to dabble in different technologies, semi-early adopt the latest operating systems and versions of software, and generally enjoy testing out new features in computer-based environments. With all that said, even I find it annoying when “designers” find the need to redesign and restructure a product’s user interface on a yearly basis.
Here’s a series of tweets from Google’s VP of Product Design which perfectly illustrate his approach to how things work.
Despite what he says about “having no beef with how Windows looks”, he contradicts himself by first stating that he dislikes the fact that it is “basically XP with a flat design skin.” Obviously the guy is allowed to have his own opinion, but his opinion will spill over into his work on Google’s product designs. That isn’t too surprising given the number and frequency of user interface changes to Google’s products and services every year.
And therein lies the problem. The vast majority of Google’s products occur on the web and on their Android platform.… Continue reading
The code first approach to using the Entity Framework can be extremely helpful in creating a new database while staying entirely within your C# code base. If you’re more comfortable with creating plain old class objects (POCO) and then having those translated into SQL driven structures, code first is for you. That said, the process by which updates to the code base are pushed to the database (migrations) can be a bit frustrating to use at times. Not all SQL Server features are supported in a code first approach. In addition, migrating your structures in Azure has its own set of problems.
If you want to roll back to a previous migration due to an error in the current migration or wanting to rewind and start over, the following command can be used from the Package Manager Console in Visual Studio. This will rewind and undo any migrations between the current and the “migration-name” migration.
update-database -TargetMigration "<migration-name>"
For example, if you have the following history of migrations in your project where the * indicates the current migration:
Use this command to roll back to the “AddColumn2” migration. Notice that the timestamp on the migration name is not included in the command.
update-database -TargetMigration "AddColumn2"
The migration history will then look like:
Notice that the migrations which were rolled back were not deleted. The next time you perform an update-database command, the migrations will be re-executed.… Continue reading
Some themes have hard coded (built in without options) lengths for excerpts on the home page, search results, and archive pages. Without the ability to change this easily, you’re left with a theme that may not suit your needs. The two choices that I find to be the easiest are to edit your functions.php file to include a filter or to install a plugin to handle this for you. Either way is fine, though you may use one over the other based on your experience with WordPress internals.
This is by far the easiest method, though not the most customizable. You’re bound by whatever the plugin allows you to change, and there’s no guarantee that the plugin will work with whatever version of WordPress is installed on your host.
- Search for the Advanced Excerpt plugin.
- Go to its settings page and choose your options.
- The first setting is the excerpt length (based on words or characters).
- The rest allows you to change what is being filtered, what text you want to show when the user can read more, and other options.
If you’re more comfortable with coding, changing WordPress internals, and have general access to the source code of your host’s WordPress installation, then this is the best option for you.
- Using a FTP client (I use FileZilla), connect to your host’s WordPress installation.
- Download and edit the functions.php file.
- Add the following to the file, where “20” is the length of the excerpt. Change that to whatever you want to use.
… Continue reading
Microsoft seems to have pushed an automatic update to Windows 7/8/8.1 machines with an annoying popup in the notification tray exclaiming that you need to reserve your copy of Windows 10 immediately. If you’re like me, you wanted to figure out how to kill this thing for good. There’s a few ways you can do it. There’s a temporary until reboot way and a permanent way.
On Windows 8.1, go to the Task Manager (right click the Task Bar, click Task Manager) or CTRL+ALT+DEL and then click Task Manager. The process you want to kill under the “Details” tab is called GWX.exe. Once you stop that process, the icon will go away. Be warned that it will come back when you reboot your machine.
- Open the Control Panel and click Windows Update.
- Click Installed Updates in the lower left.
- Find the update named “KB3035583”, right click it, and uninstall.
- Go to “C:\Windows\System32\” in an Explorer window
- Right click the “GWX” folder, click Properties and then the Security tab
- Click Advanced and then click the “Change” button next to the Owner
- Change the user to your account or group that you use on the computer
- Click OK/Apply and then delete the “GWX” folder
Your computer is now free from that annoying popup, but make sure to hide the update in the Windows Update window if it ever comes back asking to be installed. This is a good time to remind everyone that they should set their Windows Update settings to Manual Installation so that you don’t get stuck with these botched updates automatically.… Continue reading