开发者

Named elements in a FlowDocument from a ResourceDictionary

开发者 https://www.devze.com 2023-04-09 17:30 出处:网络
I have a FlowDocument (a template for a report I need to produce) stored as a resource. This seems to work well but if I name the elements I can\'t get a reference to them with FindName().

I have a FlowDocument (a template for a report I need to produce) stored as a resource. This seems to work well but if I name the elements I can't get a reference to them with FindName().

Here is the resource dictionary:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <FlowDocument x:Key="ReportStructure">
        <Paragraph Name="开发者_如何学PythonClientAddressParagraph" />
    </FlowDocument>
</ResourceDictionary>

And here is my code:

Dim _ReportResources = New ResourceDictionary() With {.Source = New Uri("/Reports/Statement.xaml", UriKind.Relative)}
Dim _FlowDocument As FlowDocument = _ReportResources.Item("ReportStructure")
Dim _Paragraph As Paragraph = _FlowDocument.FindName("ClientAddressParagraph")

' _Paragraph is Nothing (null) at this point.

Any ideas? Do I need to do some kind of initialisation on the flow document so that it registers the names of named elements?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号