MultiBinding和ContentPresenter

时间:2014-05-26 07:26:02

标签: c# wpf multibinding contentpresenter

这是我的ContentPresenter代码:

<ListBox ItemsSource="{Binding Items}" BorderThickness="0" HorizontalContentAlignment="Stretch">
<ListBox.ItemTemplate>
    <DataTemplate>
        <ContentPresenter x:Name="PART_ValueContainer">
            <ContentPresenter.Content>
                <MultiBinding>
                    <Binding Path="Value"/>
                    <Binding Path="ReadOnly"/>
                </MultiBinding>
            </ContentPresenter.Content>
            <ContentPresenter.Resources>
                <DataTemplate>
                    <TextBox IsReadOnly="{Binding Path=Content.ReadOnly, RelativeSource={RelativeSource AncestorType={x:Type ContentPresenter}}}" 
                             Text="{Binding Path=Content.Value, RelativeSource={RelativeSource AncestorType={x:Type ContentPresenter}}}" 
                                TextAlignment="Left"/>
                    </DataTemplate>
                </ContentPresenter.Resources>
            </ContentPresenter>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

我尝试从Text填充对象Items.ValueIsReadOnly的{​​{1}}。

它不起作用,我知道这不是一个好的解决方案,但是,如何做出类似的东西?

0 个答案:

没有答案