Example T503673
Visible to All Users

Reporting for WPF - How to Enable End Users to Load Custom Assemblies to the Entity Framework Context

In the Data Source wizard, it is possible to load custom assemblies by using the Browse button on the Select the Data Context page.

Choose the Data Context Page

In the End-User Designer, this button is hidden by default, so that end-users are allowed only to select the data context from assemblies referenced by the project.

Choose the Data Context Page with the Browse Button

This example illustrates how to enable this functionality in the End-User Report Designer for WPF.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

MainWindow.xaml
XAML
<Window x:Class="EnableEFBrowseButton.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:EnableEFBrowseButton" xmlns:dxrud="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner" xmlns:dxda="http://schemas.devexpress.com/winfx/2008/xaml/dataaccess" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> <UniformGrid> <Button Content="Using Customization" Click="UseCustomization" /> <Button Content="Using DataSourceWizardSettings" Click="UseDataSourceWizardSettings" /> </UniformGrid> </Window>
MainWindow.xaml.cs(vb)
C#
using DevExpress.DataAccess.EntityFramework; using DevExpress.Xpf.Core; using System.Windows; namespace EnableEFBrowseButton { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); EFDataSource.BeforeLoadCustomAssemblyGlobal += OnBeforeCustomAssemblyLoad; } void OnBeforeCustomAssemblyLoad(object sender, BeforeLoadCustomAssemblyEventArgs args) { args.AllowLoading = true; } void UseCustomization(object sender, RoutedEventArgs e) { new DXTabbedWindow() { Content = new UseEFOptionsAndCustomization() }.ShowDialog(); } void UseDataSourceWizardSettings(object sender, RoutedEventArgs e) { new DXTabbedWindow() { Content = new UseDataSourceWizardSettings() }.ShowDialog(); } } }
UseDataSourceWizardSettings.xaml
XAML
<UserControl x:Class="EnableEFBrowseButton.UseDataSourceWizardSettings" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:EnableEFBrowseButton" xmlns:dxrud="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner" xmlns:dxda="http://schemas.devexpress.com/winfx/2008/xaml/dataaccess" > <dxrud:ReportDesigner> <dxrud:ReportDesigner.DataSourceWizardSettings> <dxda:DataSourceWizardSettings EFWizardSettings="{dxda:EFWizardSettings ShowBrowseButton=True}" /> </dxrud:ReportDesigner.DataSourceWizardSettings> </dxrud:ReportDesigner> </UserControl>
UseDataSourceWizardSettings.xaml.cs(vb)
C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace EnableEFBrowseButton { /// <summary> /// Interaction logic for UseDataSourceWizardSettings.xaml /// </summary> public partial class UseDataSourceWizardSettings : UserControl { public UseDataSourceWizardSettings() { InitializeComponent(); } } }
UseEFOptionsAndCustomization.xaml
XAML
<UserControl x:Class="EnableEFBrowseButton.UseEFOptionsAndCustomization" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:EnableEFBrowseButton" xmlns:dxrud="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner" xmlns:dxrudwizard="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner/wizard" xmlns:dxda="http://schemas.devexpress.com/winfx/2008/xaml/dataaccess" > <dxrud:ReportDesigner> <dxrud:ReportDesigner.ServicesRegistry> <dxda:InstanceEntry ServiceType="{x:Type dxrudwizard:IWizardCustomizationService}"> <dxda:InstanceEntry.Instance> <local:WizardCustomizationService /> </dxda:InstanceEntry.Instance> </dxda:InstanceEntry> </dxrud:ReportDesigner.ServicesRegistry> </dxrud:ReportDesigner> </UserControl>
UseEFOptionsAndCustomization.xaml.cs(vb)
C#
using DevExpress.DataAccess.Wizard; using DevExpress.DataAccess.Wizard.Model; using DevExpress.Xpf.DataAccess.DataSourceWizard; using DevExpress.Xpf.Reports.UserDesigner.ReportWizard; using System.Windows.Controls; namespace EnableEFBrowseButton { /// <summary> /// Interaction logic for UseEFOptionsAndCustomization.xaml /// </summary> public partial class UseEFOptionsAndCustomization : UserControl { public UseEFOptionsAndCustomization() { InitializeComponent(); } } public class WizardCustomizationService : IWizardCustomizationService { public void CustomizeDataSourceWizard(DataSourceWizardCustomizationModel customization, ViewModelSourceIntegrityContainer container) { var options = container.Resolve<EFWizardOptions>() | EFWizardOptions.ShowBrowseButton; container.RegisterInstance(options); } public void CustomizeReportWizard(ReportWizardCustomizationModel customization, ViewModelSourceIntegrityContainer container) { var options = container.Resolve<EFWizardOptions>() | EFWizardOptions.ShowBrowseButton; container.RegisterInstance(options); } bool IDataSourceWizardCustomizationService.TryCreateDataSource(IDataSourceModel model, out object dataSource, out string dataMember) { dataSource = null; dataMember = null; return false; } bool IWizardCustomizationService.TryCreateReport(DevExpress.XtraReports.Wizards.XtraReportModel model, out DevExpress.XtraReports.UI.XtraReport report) { report = null; return false; } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.