Posts

Showing posts from March, 2017

How to orient WrapPanel items within ItemsControl lists vertically and horizontally

Image
Some prefer to display items contained inside a WPF WrapPanel so that they can be scrolled vertically, others prefer horizontal scrolling. This post shows how to do both, by way of some simple tweaks. Step 1: Create a new Visual Studio project Step 2: Create a ViewModel Create a ViewModel class which we use to contain details about the items we wish to display in the WrapPanel. This could include image data, text etc. To keep things simple I'll just maintain a list of strings representing the title text of each displayed item. Right-click your project and select Add > New Item. Create our MainWindowViewModel.cs class: MainWindowViewModel.cs [code language="csharp"] using System.Collections.Generic; namespace ItemsControl { public class Item { public Item(string title) { Title = title; } public string Title { get; set; } } public class MainWindowViewModel { public MainWindowViewModel() ...

Creating horizontal scrolling pages in HTML / CSS

Image
A very short description of how to create horizontal scrolling pages using HTML and CSS style sheets. Original inspiration is from this YouTube tutorial by Todd Shelton, which I have even further simplified for my needs: https://www.youtube.com/watch?v=jXto4uITMCY At this point I am a total beginner in using CSS and do not fully understand all the concepts. I am working on overcoming this. I just need to post this somewhere for my own needs... HTML content Html page with two div items containing two separate page views: index.html [code language="html"] <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="css/style.css"/> </head> <body> <!-- div that contains horizonal scroll items --> <div class="surroundContainer"> <div class="hPage">View 1</div> <div class="hPage">View 2</div> </div> </body> </htm...

Handling mouse events in WPF / MVVM using MvvmLight Event Triggers

Image
Step 1: Create a new WPF project Step 2: Install MVVM Light Select Tools > NuGet Package Manager At the prompt type: [code language="text"] Install-Package MvvmLight [/code] Step 3: Add event handling code See this link for reference https://www.technical-recipes.com/2016/using-relaycommand-icommand-to-handle-events-in-wpf-and-mvvm/ Right click your project folder and select Add > New Item > Class to add the following three classes: RelayCommand.cs [code language="csharp"] using System; using System.Windows.Input; namespace MvvmMouseEvent { public class RelayCommand<T> : ICommand { private readonly Predicate<T> _canExecute; private readonly Action<T> _execute; public RelayCommand(Action<T> execute) : this(execute, null) { _execute = execute; } public RelayCommand(Action<T> execute, Predicate<T> canExecute) { if (execute...

Tracking events in desktop applications using Google Analytics

Image
Google analytics is often associated with the recording and reporting of web page interactions, but it can easily be adapted to record user actions in a non-web desktop application too. This post helps you to get started, and assumes that you already have a Google account which you have used to create your own Analytics account. Step 1: Create a new account Log into Google Analytics and select ADMIN > ACCOUNT > Create new account. Set to a 'Mobile' application rather than 'Website'. Fill in the account details: And then select 'Get Tracking ID' to get your unique Tracking ID: A new 'EventTracker' property is created with its own unique tracking ID is created as shown: Step 2: Create a C# application to implement tracking APIs For this I use that has already been created for us by '0liver' over at GitHub. https://gist.github.com/0liver/11229128 Create a new Console application: Be sure to add the 'System....