2017-02-02 5 views
2

私はカスタムコントロールを開発しており、コントロールスタイルのセッターで2つの依存プロパティをマルチコンバータに渡したいと考えています。私のコンバータが起動しますが、値はUnsetValuesとして表示されています。RelativeSource SelfをMultiConverterにバインドする方法WPF

xmlns:custom="clr-namespace:WPFStyles.CustomControls" 
       xmlns:con="clr-namespace:WPFStyles.Converters"> 

<con:PopUpVisibilty x:Key="PopUpVisibility"/> 

<Style TargetType="{x:Type custom:PopUpNotification}"> 
    <Setter Property="MaxHeight" Value="150"/> 
    <Setter Property="MaxWidth" Value="250"/> 
    <Setter Property="Visibility"> 
     <Setter.Value> 
      <MultiBinding Converter="{StaticResource PopUpVisibility}"> 
       <Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type custom:PopUpNotification}}" Path="IsOpen"/> 
       <Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type custom:PopUpNotification}}" Path="Header"/> 
      </MultiBinding> 
     </Setter.Value> 
    </Setter> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type custom:PopUpNotification}"> 

これらのプロパティを正しく渡す方法については、どのような助けもあります。

+0

'RelativeSourceは、= {RelativeSource自己}'動作しませんでしたか? –

+1

うわー、私はそこそこ馬鹿になりました、ありがとうございました。 – user3519506

答えて

3

私はこれが機能することを期待します:

<MultiBinding Converter="{StaticResource PopUpVisibility}"> 
    <Binding RelativeSource="{RelativeSource Self}" Path="IsOpen"/> 
    <Binding RelativeSource="{RelativeSource Self}" Path="Header"/> 
</MultiBinding> 
関連する問題