■ 부모 엘리먼트에서 정의한 속성 바인딩 하기

----------------------------------------------------------------------------------------------------

<UserControl

    x:Class="TestProject.MultiComboBox"

    ...

    d:DesignHeight="30">

    <Grid Name="grid" Margin="0">

        <Button Name="button"

            Margin="0"

            ...

            Padding="0">

            ...

        </Button>

        <Popup Name="popup"            

            MinWidth="{Binding ElementName=button, Path=ActualWidth}"

            MinHeight="100"

            Width="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=PopupWidth}"

            Height="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=PopupHeight}"

            PlacementTarget="{Binding ElementName=button}"

            Placement="Bottom"

            IsOpen="False"

            StaysOpen="False">

            ...

        </Popup>

    </Grid>

</UserControl>

----------------------------------------------------------------------------------------------------

※ PopupWidth 및 PopupHeight 속성은 UserControl을 상속한 MultiComboBox 클래스에서 정의한 의존 속성이다.

Posted by 사용자 icodebroker
TAG