In the Data Source wizard, it is possible to load custom assemblies by using the Browse button on the Select 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.
This example illustrates how to enable this functionality in the End-User Report Designer for WPF.
Files to Review
- MainWindow.xaml (VB: MainWindow.xaml)
- MainWindow.xaml.cs (VB: MainWindow.xaml.vb)
- UseDataSourceWizardSettings.xaml (VB: UseDataSourceWizardSettings.xaml)
- UseDataSourceWizardSettings.xaml.cs (VB: UseDataSourceWizardSettings.xaml.vb)
- UseEFOptionsAndCustomization.xaml (VB: UseEFOptionsAndCustomization.xaml)
- UseEFOptionsAndCustomization.xaml.cs (VB: UseEFOptionsAndCustomization.xaml.vb)
Documentation
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
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>
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();
}
}
}
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>
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();
}
}
}
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>
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;
}
}
}