Presentation is loading. Please wait.

Presentation is loading. Please wait.

Virtual techdays INDIA │ 22-24 Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri.

Similar presentations


Presentation on theme: "Virtual techdays INDIA │ 22-24 Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri."— Presentation transcript:

1 virtual techdays INDIA │ 22-24 Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri │ Consultant, Microsoft

2 virtual techdays  Introduction  Application – Level Add-ins  VSTO 4 Framework  How the Office app loads the Add-in  Customizing the Office Ribbon  Custom Task Panes in Office  Using WPF Controls in Office Solutions S E S S I O N A G E N D A

3 virtual techdays Prerequisites Office 2007 SP2/Office 2010 Windows 7.net framework 4 The Visual Studio 2010 Tools for Office Runtime.

4 virtual techdays Introduction Visual Studio provides the following types of project templates for Office development: – Document-level customizations. This type of solution is associated with a specific document. – Application-level add-ins. This type of solution is associated with the application itself. To decide which of these project types is best for your solution, think about whether you want your code to run only when a specific document is open, or whether you want the code to be available whenever the application is running. We will focus on Application-level add-in development in our session today.

5 virtual techdays Application-Level Add-Ins Application-level add-ins consist of an assembly that is associated with a Microsoft Office application. Visual Studio includes tools to help you create add-ins. Add-in projects include an automatically generated class that represents the add-in. This class provides properties and events you can use to access the object model of the host application and run code when the add-in is loaded and shut down.

6 virtual techdays VSTO and.net framework

7 virtual techdays How the Office App loads the Add-in

8 virtual techdays Optional slide The following steps occur when a user starts an application: The application checks the registry for entries that identify add-ins that were created by using the Office developer tools in Visual Studio. If the application finds these registry entries, the application loads VSTOEE.dll, which loads VSTOLoader.dll. These are unmanaged DLLs that are the loader components for the Visual Studio 2010 Tools for Office Runtime. For more information, see Visual Studio Tools for Office Runtime Overview.Visual Studio Tools for Office Runtime Overview VSTOLoader.dll loads the.NET Framework and starts the managed portion of the Visual Studio Tools for Office runtime. The Visual Studio Tools for Office runtime checks for manifest updates, and downloads the most recent application and deployment manifests. The Visual Studio Tools for Office runtime performs a series of security checks. For more information, see Securing Office Solutions.Securing Office Solutions If the add-in is trusted to run, the Visual Studio Tools for Office runtime uses the deployment manifest and application manifest to check for assembly updates. If a new version of the assembly is available, the runtime downloads the new version of the assembly to the ClickOnce cache on the client computer. For more information, see Deploying Office Solutions.Deploying Office Solutions The Visual Studio Tools for Office runtime creates a new application domain in which to load the add-in assembly. The Visual Studio Tools for Office runtime loads the add-in assembly into the application domain. The Visual Studio Tools for Office runtime calls the RequestComAddInAutomationService method in your add-in, if you have overridden it.RequestComAddInAutomationService You can optionally override this method to expose an object in your add-in to other Microsoft Office solutions. For more information, see Calling Code in Application-Level Add-ins from Other Office Solutions.Calling Code in Application-Level Add-ins from Other Office Solutions The Visual Studio Tools for Office runtime calls the RequestService method in your add-in, if you have overridden it.RequestService You can optionally override this method to extend a Microsoft Office feature by returning an object that implements an extensibility interface. For more information, see Customizing UI Features By Using Extensibility Interfaces.Customizing UI Features By Using Extensibility Interfaces

9 virtual techdays Customizing the Office Ribbon To add a Ribbon to a project – On the Project Menu, click Add New Item. – In the Add New Item dialog box, select Ribbon (Visual Designer) or Ribbon (XML). For more information about these templates, see Ribbon Overview.Ribbon Overview – In the Name box, type a name for the Ribbon item. Click OK. Handling Events and Setting Properties – The Ribbon Designer enables you to set control properties at design time by using the Properties window. In addition, the Ribbon exposes a strongly typed object model that you can use to get and set the properties of Ribbon controls at run time. – You can double-click any control on the designer to open an event handler for the control's default event. You can create event handlers for all other control events by using the Properties window. – Ribbon events and properties are located in the Microsoft.Office.Tools.Ribbon namespace. The Ribbon (Visual Designer) item automatically adds a reference to this assembly in the project and inserts the appropriate using or Imports statement at the top of the Ribbon code file.Microsoft.Office.Tools.Ribbon

10 virtual techdays DEMO: Customizing Ribbon in Office

11 virtual techdays Custom Task-panes in Office Custom Task Panes Overview – Task panes are user interface panels that are typically docked to one side of a window in a Microsoft Office application. Custom task panes give you a way to create your own task pane and provide users with a familiar interface to access your solution's features. For example, the interface can contain controls that run code to modify documents or display data from a data source. Benefits of Custom Task Panes Custom task panes let you integrate your features into a familiar user interface. You can create a custom task pane quickly by using Visual Studio tools. – Familiar User Interface Users of applications in the Microsoft Office system are already familiar with using task panes such as the Styles and Formatting task pane in Word. Custom task panes behave like other task panes in the Microsoft Office system. Users can dock custom task panes to different sides of the application window, or they can drag custom task panes to any location in the window. You can create an add-in that displays multiple custom task panes at the same time, and users can control each task pane individually. – Windows Forms Support The user interface of a custom task pane that you create by using the Office development tools in Visual Studio is based on Windows Forms controls. You can use the familiar Windows Forms Designer to design the user interface for a custom task pane. You can also use the data binding support in Windows Forms to bind a data source to controls on the task pane. Creating a Custom Task Pane You can create a basic custom task pane in two steps: Create a user interface for your custom task pane by adding Windows Forms controls to a UserControl object. UserControl Instantiate the custom task pane by passing the user control to the CustomTaskPaneCollection object in your add-in. This collection returns a new CustomTaskPane object that you can use to modify the appearance of the task pane and respond to user events.CustomTaskPaneCollectionCustomTaskPane

12 virtual techdays Custom Task Panes in Office You can add a custom task pane to the applications listed above by using an application-level add-in. To add a custom task pane to an application – Open or create an application-level project for one of the applications listed above. – On the Project menu, click Add User Control. – In the Add New Item dialog box, change the name of the new user control to MyUserControl, and then click Add. – The user control opens in the designer. – Add one or more Windows Forms controls from the Toolbox to the user control. – Open the ThisAddIn.cs or ThisAddIn.vb code file. – Add code to the ThisAddIn class. private MyUserControl myUserControl1; private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane; – Add the following code to the ThisAddIn_Startup event handler myUserControl1 = new MyUserControl(); myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl1, "My Task Pane"); myCustomTaskPane.Visible = true;

13 virtual techdays DEMO: Custom Task Panes in Office

14 virtual techdays Using WPF Controls in Office Solutions Adding WPF Controls to Office Projects at Design Time – You cannot add WPF controls directly to UI elements in Office solutions. Instead, add a User Control (Winforms) item to your project, and use it as the design surface for WPF controls. Then, add the WPF user control to a UI element in your project. To add WPF controls to an actions pane, custom task pane, or form region – Open a project to which you want to add a custom task pane, an actions pane, or a form region. – Add a User Control (Winforms) item to your project. – From the Toolbox, add WPF controls to the WPF user control design surface. – By default, when the WPF user control designer is open, the Toolbox contains only WPF controls. – Build the project. – Add an actions pane, form region, or custom task pane to your project: – For form regions, add an Outlook Form Region item to the project. – For actions panes, add an Actions Pane Control or User Control item to the project. – For custom task panes, add a User Control item to the project. – From the ProjectName WPF User Controls tab of the Toolbox, drag the WPF user control to the designer for the actions pane, form region, or custom task pane. – Visual Studio automatically creates an ElementHost object that hosts the WPF user control on the UI element.ElementHost – Rebuild the project.

15 virtual techdays Using WPF – contd… Hosting WPF Controls by Using the ElementHost Class – Visual Studio provides features that help you use Windows Forms controls in your Office solutions, but it does not provide similar features for WPF controls. For example, you can add Windows Forms controls to documents and worksheets at design time by dragging controls from the Toolbox, or at run time by using helper methods. However, these tools are not available for WPF controls. – WPF controls use the ElementHost class as an integration layer between a Windows Forms control or form and the WPF controls. When you add WPF controls to your solution at design time, Visual Studio automatically generates an ElementHost object for you.ElementHost

16 virtual techdays DEMO: WPF Controls in Office

17 virtual techdays Sarang.datye@microsoft.com │ www.dotnetbetaworks.com Sridhar.poduri@microsoft.com │


Download ppt "Virtual techdays INDIA │ 22-24 Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri."

Similar presentations


Ads by Google