C# 以编程方式编辑文本时删除内容控件
根据(我的重点): 如果临时属性为true,当用户在控件中键入内容时,ContentControl将自动删除,,或者当以编程方式更改控件中的文本时,。当ContentControl自动从文档中删除时,控件中的文本仍保留在文档中 它使用Word Editor处理“当用户在控件中键入时”,但在(C#)代码中更改文本时不起作用。我的代码如下C# 以编程方式编辑文本时删除内容控件,c#,openxml-sdk,C#,Openxml Sdk,根据(我的重点): 如果临时属性为true,当用户在控件中键入内容时,ContentControl将自动删除,,或者当以编程方式更改控件中的文本时,。当ContentControl自动从文档中删除时,控件中的文本仍保留在文档中 它使用Word Editor处理“当用户在控件中键入时”,但在(C#)代码中更改文本时不起作用。我的代码如下 做一个临时的标签 static void MakeTagsTemporary(List<Tag> tagList) { tagList.For
static void MakeTagsTemporary(List<Tag> tagList)
{
tagList.ForEach(x => x.Parent.Append(new TemporarySdt() { Val = true }));
} mainPart.Document.Save();
static void MakeTagsTemporary(列表标记列表)
{
tagList.ForEach(x=>x.Parent.Append(new-TemporarySdt(){Val=true}));
}mainPart.Document.Save();
我特别保存是为了接受将内容控件设置为临时的更改,但不会产生任何效果static void ApplyProductGrid(MainDocumentPart mainPart, Plan pl, List<Tag> tagList)
{
foreach (Tag tagitem in tagList)
{
string GridValue = pl.FormattedTags.Where(x => x.Key == tagitem.Val).Select(x => x.Value).FirstOrDefault();
tagitem.Parent.Parent.Descendants<Text>().FirstOrDefault().Text = GridValue;
}
}
静态无效ApplyProductGrid(MainDocumentPart mainPart、Plan pl、List tagList)
{
foreach(标记列表中的标记tagitem)
{
string GridValue=pl.FormattedTags.Where(x=>x.Key==tagitem.Val)。选择(x=>x.Value)。FirstOrDefault();
tagitem.Parent.Parent.subjections().FirstOrDefault().Text=GridValue;
}
}
tagitem.Parent.Parent.subjections().FirstOrDefault().Text=GridValue代码>正在执行其工作,它正在更新值,但未删除内容控件
当我从word编辑某些内容时,内容控件将被删除