如何将多绑定结果数据绑定到DependencyProperty

时间:2014-11-26 11:50:38

标签: c# wpf xaml data-binding

如何将MultiBinding的结果分配给DependencyProperty?

具体来说,我希望将“Details”DependencyProperty绑定到DetailsEditor.Text。

用户控件:

<TextBox x:Name="DetailsEditor">
    <TextBox.Text>
        <MultiBinding Converter="{StaticResource FilesToInstructionsConverter}" ConverterParameter=".dll|.exe|.config" 
                      UpdateSourceTrigger="PropertyChanged" >
            <Binding ElementName="UserControl" Path="SourceDirectory"  UpdateSourceTrigger="PropertyChanged" />
            <Binding ElementName="UserControl" Path="DestinationDirectory" UpdateSourceTrigger="PropertyChanged" />
        </MultiBinding>
    </TextBox.Text>
</TextBox>

UserControl的代码隐藏:

public string Details
    {
        get { return (string)GetValue(DetailsProperty); }
        set { SetValue(DetailsProperty, value); }
    }

    public static readonly DependencyProperty DetailsProperty =
        DependencyProperty.Register("Details", typeof(string), typeof(DirectivesControl), null);

0 个答案:

没有答案