When a DropDownList SDT form is saved in a XAML document and then imported with the XamlFormatProvider, an extra ListItem entry is added in the items collection of the DropDownList. The extra entry is the default "Choose an item".
To work this around, iterate all ComboBoxProperties and manually remove duplicates of the "Choose an item" entry.
var dropDownLists = radRichTextBox.Document.EnumerateChildrenOfType<SdtRangeStart>()
.Where(x => x.SdtProperties is ComboBoxProperties)
.Select(x => x.SdtProperties).OfType<ComboBoxProperties>();
var defaultItemString = LocalizationManager.GetString("Documents_ContentControlsGenerator_ListItem");
foreach (var item in dropDownLists)
{
if (item.Items.Count > 0 && item.Items.Any(x => x.Value != defaultItemString) && item.Items.Any(x => x.Value == defaultItemString))
{
var occurrence = item.Items.FirstOrDefault(x => x.Value == defaultItemString);
while (occurrence != null)
{
item.Items.Remove(occurrence);
occurrence = item.Items.FirstOrDefault(x => x.Value == defaultItemString);
}
}
}
We want to have the option to replace texts only in a selected part of the document.
Use Notepad++ as a reference to check this feature.
RadSpreadsheetFormulaBar has a drop down list that shows the named ranges in the document. If a named range contains an underscore character (ex: Income_Amount), the associated item in the drop down won't display the underscore (ex: IncomeAmount).
To workaround this, you can use a global Loaded event handler of RadMenuItem and override the Header content with a TextBlock.
static MainWindow()
{
EventManager.RegisterClassHandler(typeof(RadMenuItem), RadMenuItem.LoadedEvent, new RoutedEventHandler(OnMenuItemLoaded));
}
private static void OnMenuItemLoaded(object sender, RoutedEventArgs e)
{
var menuItem = (RadMenuItem)sender;
if (menuItem.DataContext is DefinedName context)
{
menuItem.Header = new TextBlock() { Text = context.Name };
}
}
Add protection mode that allows to make the document readonly, but allow forms editing. In MS Word this can be enabled via the "Restrict Editing" menu. The option is called "Filling in forms" and protects the document, but leaves the Sdt elements (the forms) editable.