WPF Layer Cake C#, C++/CLI and C

Slides:



Advertisements
Similar presentations
MVVM Overview Frank Shoemaker MindCrafted Systems
Advertisements

Module 1: Creating an Application by Using Windows Presentation Foundation Overview of WPF Creating a Simple WPF Application Handling Events and Commands.
Creating Windows Store Apps. 1. Overview of Windows Store applications 2. Worked example 3. Adding controls and event handlers Contents 2.
Introduction to Windows Presentation Foundation (WPF) Dr. Frank McCown COMP 445 – GUI Programming.
Lessons learned from developing a Windows 8 Metro application in C# Frode Nilsen Nilsen Labs Ticki.
An Introduction to the Model-View-ViewModel Pattern Srsly? Another MV* Pattern? Srsly? Another MV* Pattern?
Dinko Jakovljević Microsoft Student Partner | BambooLab
WinRT Apps
WPF. Origins – Who, When, Where  Who? Microsoft  When? November 2006  Where? Windows Vista Windows Server 2003 Windows XP Service Pack 2.
Real world Windows Phone development Igor
Building Silverlight Applications Using the MVVM pattern An Introduction by Peter Messenger Senior Developer – Qmastor

ASP.Net, Web Forms and Web Controls 1 Outline Introduction Simple HTTP Transaction System Architecture Creating and Running a Simple Web Form Example Web.
.NET Database Technologies: Introduction to WPF and Entity Framework DataBinding.
Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University.
Target: dependency property Source: any public property CLR and WPF properties Target: dependency property Source: any public property CLR and WPF properties.
Module 11 Control Customization. Module Overview Overview of Control Authoring Creating Controls Managing Control Appearance by Using Visual States Integrating.
1 Intro XAML Attribute syntax & property syntax Panels Reusable resources Controls Data binding Steen Jensen, spring 2014.
Xamarin.Forms Hands On.
Windows Presentation Foundation. Agenda Introduction Developing Applications WPF and WF interoperability Custom Controls Styles and Templates Data Binding.
Data Binding to Controls Programming in C# Data Binding to Controls CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
V 1.0 Programming III. Comparison of GUI APIs WPF Hello World UI elements Content models Inheritance chains.
C# Events and WPF #W5. Horizontal Prototype WPF Designed for rapid user interface design Used for many devices: Windows Phone, Tablets, PCs,
Windows Presentation Foundation Adam Calderon Principal Engineer Interknowlogy LLC
Разработка Windows 8 приложений на С++ Сергей Байдачный Специалист по разработке программного обеспечения Microsoft Ukraine.
Adam Calderon – C# MVP Application Development Practice Lead Interknowlogy.
Internet Technologies and Web Application Web Services With ASP.NET Tutorial: Introduction to.
Claudio Lassala Software Developer EPS Software / CODE Magazine Session Code: DEV 201.
V 1.0 Programming III. Automatic notifications (…Changed, INofityPropertyChanged, ObservableCollection ) Data formatters Data conversions Resources.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
Declarative based UI programming: WPF, Silverlight & Surface Tim Huckaby CEO, InterKnowlogy Microsoft RD & MVP.
Introduction to Building Windows 8.1 & Windows Phone Applications.
Sample Application Multi Layered Architecture (n-tier): –Graphical User Interface (GUI): Forms, components, controls The Visual Designer in Visual Studio.
Windows Phone MVVM and Unit Testing Step by Step Andy Wigley Windows Phone Development MVP, Mobile Software Consultant APPA Mundi Ltd WPH208.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Windows Presentation Foundation Ruwan Wijesinghe.
Object Oriented Software Development 10. Persistent Storage.
Windows Presentation Foundation (WPF). Introduction Separates appearance of user interface from behavior Appearance usually specified by XAML Behavior.
More exercises with C# Fateme Rajabi #W6. Add an image to your project Right click on your project name in solution explorer Add -> Existing item -> browse.
Windows 10 UWP MVVM In Depth
1 Catching up on Rich Clients (round 1) Mike Ormond, Mike Taulty Developer & Platform Group Microsoft Ltd
Module 4 Taking Control of the User Interface. Module Overview Sharing Logical Resources in an Application Creating Consistent User Interfaces by Using.
5-1 VISUAL J++ Colorado Technical University IT420 Tim Peterson.
3 private void equalsButton_Click( object sender, RoutedEventArgs e) { calculateResult(); }
Architecture Multi Layered Architecture (n-tier): Application: Model Controllers Database Access Graphical User Interface (GUI): Forms, components, controls.
V 1.0 Programming III. Automatic notifications with data binding (…Changed, INofityPropertyChanged, ObservableCollection, DataTemplate) Data formatters.
CPSC 481 – Week #7 Sowmya Somanath
Module 1 Introducing C# and the.NET Framework. Module Overview Introduction to the.NET Framework 4 Creating Projects Within Visual Studio 2010 Writing.
V 1.0 Programming III. XAML Data Binding I.. V 1.0ÓE-NIK, 2014 XAML namespaces Namespaces define the allowed tags and attributes The one without the prefix.
User Interface Programming in C#: Basics and Events Chris North CS 3724: HCI.
Model View ViewModel Architecture. MVVM Architecture components.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Windows Presentation Foundation Ruwan Wijesinghe.
REC [ ] How to implement CAMERA RECORDING for USB WEBCAM or IP CAMERA in C#.NET SOURCE CODE: ! Welcome to this presentation that explains.
Windows 8 apps and the MVVM pattern SILVERLIGHTSHOW.NET WEBINARS SERIES GILL CLEEREN, October 16 th
Programming with MVVM Miguel A. Castro Architect -
Andy Wigley Device Application Development MVP APPA Mundi Ltd SESSION CODE: WEM309.
Creating rich applications using Model View ViewModel David Ross
Part of the Microsoft.NET Framework 3.0 Tomer Shamam.NET Technologies Expert Sela Group
Data Binding, Binding Properties Doncho Minkov Telerik School Academy Technical Trainer
WPF apps can now run well in a Multi Monitor Setup with different DPIs, enabled via manifest setting true/PM New events and.
In Windows 8 Store Applications
State of the Art in Mobile Development - AndRES Käver, 2016
Ben Riga 02 | Basics of View Models Ben Riga
Jim Fawcett CSE687-OnLine – Object Oriented Design Summer 2017
Miguel A. Castro Architect IDesign
Glenn Block MEF in the real world Glenn Block
Gathering User Input Event Handling Create Dynamic controls
Page Navigation and Data Binding in Windows Runtime Apps
A very brief introduction
Data/Code driven UI using WPF part 2
Brown Bag Seminar Summer 2007
Presentation transcript:

WPF Layer Cake C#, C++/CLI and C Andy Dent www.andydent.com May 2009

Background Clunky old C, must be preserved with strong OO design and lots of code coupled to data. New GUI required. Rich Internet App is appealing for future. Long-term change – core IP of company.

Clunky old C, must be preserved with strong OO design and lots of code coupled to data. New GUI required. Rich Internet App is appealing for future. Long-term change – core IP of company. ViewModel = all state of the GUI preserved in an external object so GUI is very lightweight, makes testing possible as can invoke all state changes through ViewModel interface.

Wandering in WPF Continuum of structuring a WPF program: Ain’t it cool – do as much in XAML as possible, binding data and all commands/events. Events bound in XAML, commands in code. Bind data only in XAML. XAML for layout, code for all bindings. Silly opposite extreme – no XAML I have a natural tendency to using a declarative style and there is a certain geeky appeal to doing as much as possible in XAML.

<Window.CommandBindings> Command="{x:Static w:TestDespatchWindow.cmdShow2}" Executed="OnShow2" /> </Window.CommandBindings> <Window.InputBindings> <KeyBinding Key="T" Modifiers="Control" Command="{x:Static w:TestDespatchWindow.cmdShow2}" /> </Window.InputBindings> <DockPanel> <Menu DockPanel.Dock="Top"> <MenuItem Header="_File" > <MenuItem Header="E_xit" Command="Close" /> </MenuItem> <MenuItem Header="Test"> <MenuItem </Menu> <StackPanel Margin="0,8,0,0"> <Button x:Name="Show2EventBased" Margin="10,2,10,2" Click="OnShow2" Content="Show2 via WPF Event"/> <Button x:Name="Show2Command" Margin="10,2,10,2" Content="Show2 via WPF"/> <Button x:Name="Show2IndirectCommand" Margin="10,2,10,2" Content="Show2 via DLL" />

public partial class WindowWithCommandVM : Window { public WindowWithCommandVM() InitializeComponent(); mBackend = new BackedCommandViewModel( "Fred Nerk", "10 Bloggs Ave\nToon Town", true); ... DataContext = mBackend; NameEntry.SetBinding( TextBox.TextProperty, new Binding("Name") {Mode = BindingMode.TwoWay} ); CNTL_Lower.Command = mBackend.cmdLower; CommandBindings.Add( new CommandBinding(mBackend.cmdLower, mBackend.CommandSingleEntryPoint) );

public ref class BackedCommandViewModel : public INotifyPropertyChanged { public: BackedCommandViewModel( String^ _name, String^ _address); ... void CommandSingleEntryPoint( Object^ sender, ExecutedRoutedEventArgs^ e); property String^ Name { String^ get(); void set(String^ s); }; property String^ Address { String^ get();... property RoutedCommand^ cmdLower { RoutedCommand^ get(); };... virtual event PropertyChangedEventHandler^ PropertyChanged; private: void OnPropertyChanged(String^ name) PropertyChanged(this, gcnew PropertyChangedEventArgs(name)); }

Lessons Learned Don’t fight C# - do hookups of properties and commands in code-behind files. C++/CLI can define straightforward Property objects, events, delegates and commands. Debugging all the way works if you tell your app it should debug unmanaged code. Beware of #includes in C++/CLI – use referenced assemblies C2011 'class' type redefinition The common error C2011 occurs normally because people forget to have ifndef/define guards or pragma once.Error 1 error C2011: 'CPPDemoViewModel::SimpleViewModel' : 'class' type redefinition However, the simplest initial version of CPPViewModelTest testing CPPDemoViewModel came up with the C2011 error. Because this is a common beginners error, it is virtually impossible to find an answer on Google. I did find one instance of someone triggering it in the same circumstances (in Sep 2008) but nobody had provided a useful answer. The key turned out to be the traditional include "CPPDemoViewModel.h" which brings the class definitions of namespace CPPViewModelTest into UnitTest_CPPViewModel.cpp as you would for any C++ compilation using a library. CPPViewModelTest is defined in the assembly CPPDemoViewModel and that assembly is explicitly recorded as a Reference of the project CPPViewModelTest. The reference imports the namespace into the list of available namespaces but does not trigger the pragma once protection (which I regard as a C++/CLI compilation bug). Hence the C2011 occurring as if the class definition wasn't guarded. Note that the project CPPViewModelTest also has a dependency on the project CPPDemoViewModel which is there to guarantee builds are triggered. Tests Fail with System.IO.FileNotFoundException This is the for specific circumstance when a pure C DLL is included in a C# assembly - it doesn't get propagated from the C++/CLI assembly which uses it, despite settings to copy dependents.It will build OK but get a runtime System.IO.FileNotFoundException as described here because of a failure to find BackingStore.dll. This was fixed by adding a test configuration (right-click Solution - Add) ConfigRequiringBackingStore which specifies that BackingStored.dll must be deployed.