Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 流程文档和数据绑定_Wpf_Data Binding_Flowdocument - Fatal编程技术网

Wpf 流程文档和数据绑定

Wpf 流程文档和数据绑定,wpf,data-binding,flowdocument,Wpf,Data Binding,Flowdocument,在彻底阅读了关于flowdocuments(在WPF中)的文档之后,似乎flowdocument不容易支持数据绑定。请说这不是真的!我有一个使用ExpressionBlend中的示例数据的列表框,并在flowdocument中插入了一个textblock。textblock(文本属性)数据索引到列表框中的字符串数据。运行该项目后,我希望textblock文本会随着列表框选择的更改而更改,但什么也没有发生。数据绑定不起作用。使用flowdocument进行数据绑定的最简单方法是什么 这是XAML

在彻底阅读了关于flowdocuments(在WPF中)的文档之后,似乎flowdocument不容易支持数据绑定。请说这不是真的!我有一个使用ExpressionBlend中的示例数据的列表框,并在flowdocument中插入了一个textblock。textblock(文本属性)数据索引到列表框中的字符串数据。运行该项目后,我希望textblock文本会随着列表框选择的更改而更改,但什么也没有发生。数据绑定不起作用。使用flowdocument进行数据绑定的最简单方法是什么

这是XAML

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Window.Resources>
    <DataTemplate x:Key="ItemTemplate">
        <StackPanel>
            <TextBlock Text="{Binding Property1}"/>
            </StackPanel>
    </DataTemplate>
</Window.Resources>

<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
    <FlowDocumentScrollViewer Margin="120,64,256,126">
        <FlowDocument>
            <Paragraph><Run Text="Only A Test"/><InlineUIContainer>
                    <TextBlock TextWrapping="Wrap" Text="{Binding Collection[0].Property1}" Height="56" Width="112"/>
                </InlineUIContainer></Paragraph>
        </FlowDocument>
    </FlowDocumentScrollViewer>
    <ListBox ItemTemplate="{DynamicResource ItemTemplate}" ItemsSource="{Binding Collection}" Margin="0,83.847,52,62.153" HorizontalAlignment="Right" Width="200"/>
</Grid>
</Window>

根据2009年4月的数据,这是不可能的:

虽然flow文档中有很多很棒的特性,但是如果您的文档是从动态数据生成的,那么您会遇到一个小问题:flow文档中不支持数据绑定。流文档元素(节、表、运行、段落等)是依赖项对象,但不定义任何允许动态更改或生成内容的依赖项属性


请出示你的XAML。我肯定有人知道答案。