[C#/WPF/DEVEXPRESS] RichEditControl 클래스 : 메일 병합 사용하기
■ RichEditControl 클래스에서 메일 병합을 사용하는 방법을 보여준다. ▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon" xmlns:dxre="http://schemas.devexpress.com/winfx/2008/xaml/richedit" Width="800" Height="600" Title="메일 병합 실행하기"> <Window.Resources> <ResourceDictionary> <dxre:RichEditUICommand x:Key="RichEditUICommandKey" /> </ResourceDictionary> </Window.Resources> <Grid> <dxb:BarManager x:Name="barManager" ToolbarGlyphSize="Small"> <dxb:BarManager.Items> <dxb:BarButtonItem x:Name="fileNewBarButtonItem" Command="{Binding Path=FileNew, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="fileOpenBarButtonItem" Command="{Binding Path=FileOpen, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="fileSaveAsBarButtonItem" Command="{Binding Path=FileSaveAs, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="filePrintBarButtonItem" Command="{Binding Path=FilePrint, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="filePrintPreviewBarButtonItem" Command="{Binding Path=FilePrintPreview, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="editUndoBarButtonItem" Command="{Binding Path=EditUndo, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="editRedoBarButtonItem" Command="{Binding Path=EditRedo, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarSubItem x:Name="mailMergeInsertFieldPlaceholderBarSubItem" Command="{Binding Path=MailMergeInsertFieldPlaceholder, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}"> <dxb:BarSubItem.ItemLinks> <dxre:InsertMergeFieldsBarListItemLink BarItemName="mailMergeInsertFieldListInsertMergeFieldsBarListItem"/> </dxb:BarSubItem.ItemLinks> </dxb:BarSubItem> <dxre:InsertMergeFieldsBarListItem x:Name="mailMergeInsertFieldListInsertMergeFieldsBarListItem" RichEditControl="{Binding ElementName=richEditControl}" /> <dxb:BarCheckItem x:Name="mailMergeViewMergedDataBarCheckItem" Command="{Binding Path=MailMergeViewMergedData, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="mailMergeShowAllFieldCodesBarButtonItem" Command="{Binding Path=MailMergeShowAllFieldCodes, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="mailMergeShowAllFieldResultsBarButtonItem" Command="{Binding Path=MailMergeShowAllFieldResults, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="mailMergeFirstDataRecordBarButtonItem" Command="{Binding Path=MailMergeFirstDataRecord, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="mailMergePreviousDataRecordBarButtonItem" Command="{Binding Path=MailMergePreviousDataRecord, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="mailMergeNextDataRecordBarButtonItem" Command="{Binding Path=MailMergeNextDataRecord, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="mailMergeLastDataRecordBarButtonItem" Command="{Binding Path=MailMergeLastDataRecord, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> <dxb:BarButtonItem x:Name="mailMergeSaveDocumentAsBarButtonItem" Command="{Binding Path=MailMergeSaveDocumentAs, Mode=OneTime, Source={StaticResource RichEditUICommandKey}}" CommandParameter="{Binding ElementName=richEditControl}" /> </dxb:BarManager.Items> <DockPanel> <dxr:RibbonControl DockPanel.Dock="Top"> <dxr:RibbonDefaultPageCategory> <dxr:RibbonPage x:Name="fileRibbonPage" Caption="File"> <dxr:RibbonPageGroup x:Name="grpCommon" Caption="Common"> <dxb:BarButtonItemLink BarItemName="fileNewBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="fileOpenBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="fileSaveAsBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="filePrintBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="filePrintPreviewBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="editUndoBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="editRedoBarButtonItem" /> </dxr:RibbonPageGroup> </dxr:RibbonPage> <dxr:RibbonPage x:Name="mailingsRibbonPage" Caption="Mailings"> <dxr:RibbonPageGroup x:Name="writeInsertFieldsRibbonPageGroup" Caption="Write & Insert Fields"> <dxb:BarSubItemLink BarItemName="mailMergeInsertFieldPlaceholderBarSubItem" /> </dxr:RibbonPageGroup> <dxr:RibbonPageGroup x:Name="previewResultsRibbonPageGroup" Caption="Preview Results"> <dxb:BarCheckItemLink BarItemName="mailMergeViewMergedDataBarCheckItem" /> <dxb:BarButtonItemLink BarItemName="mailMergeShowAllFieldCodesBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="mailMergeShowAllFieldResultsBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="mailMergeFirstDataRecordBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="mailMergePreviousDataRecordBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="mailMergeNextDataRecordBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="mailMergeLastDataRecordBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="mailMergeSaveDocumentAsBarButtonItem" /> </dxr:RibbonPageGroup> </dxr:RibbonPage> </dxr:RibbonDefaultPageCategory> </dxr:RibbonControl> <dxre:RichEditControl x:Name="richEditControl" BarManager="{Binding ElementName=barManager, Mode=OneTime}" Loaded="richEditControl_Loaded" /> </DockPanel> </dxb:BarManager> </Grid> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
using System.Windows; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private //////////////////////////////////////////////////////////////////////////////// Event #region 리치 에디터 컨트롤 로드시 처리하기 - richEditControl_Loaded(pSender, e) /// <summary> /// 리치 에디터 컨트롤 로드시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void richEditControl_Loaded(object sender, RoutedEventArgs e) { this.richEditControl.Options.MailMerge.DataSource = new EmployeeList().GetData(); this.richEditControl.Options.MailMerge.ViewMergedData = true; } #endregion } } |
TestProject.zip