[C#/WPF] Binding 태그 확장 : RelativeSource 속성에서 RelativeSource 태그 확장을 사용해 상위 엘리먼트 속성 바인딩하기
C#/WPF 2015. 10. 7. 05:27■ Binding 태그 확장 : RelativeSource 속성에서 RelativeSource 태그 확장을 사용해 상위 엘리먼트 속성 바인딩하기
------------------------------------------------------------------------------------------------------------------------
<ListBox x:Class="TestProject.MultiListBox" ...>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="1" Orientation="Horizontal">
<CheckBox Name="itemCheckBox"
VerticalAlignment="Center"
Width="20"
IsChecked="{Binding IsChecked}" />
<Image Name="itemImage"
VerticalAlignment="Center"
Margin="0 0 5 0"
Width="16"
Height="16"
Stretch="None"
Source="{Binding Icon}" />
<TextBlock Name="itemTextBlock"
VerticalAlignment="Center"
Margin="0"
Width="{Binding RelativeSource={RelativeSource AncestorType=ScrollContentPresenter, Mode=FindAncestor}, Path=ActualWidth}"
Text="{Binding Text}" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Icon}" Value="{x:Null}">
<Setter TargetName="itemImage" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
------------------------------------------------------------------------------------------------------------------------
'C# > WPF' 카테고리의 다른 글
[C#/WPF] ColorAnimationUsingKeyFrames 엘리먼트 사용하기 (0) | 2015.10.08 |
---|---|
[C#/WPF] StringAnimationUsingKeyFrames 엘리먼트 : 문자열 교대로 표시하기 (0) | 2015.10.08 |
[C#/WPF] DoubleAnimationUsingKeyFrames 엘리먼트 : 문자열 교대로 표시하기 (0) | 2015.10.08 |
[C#/WPF] PointAnimationUsingKeyFrames 엘리먼트 : 공 튕기기 (0) | 2015.10.08 |
[C#/WPF] DoubleAnimation 엘리먼트 : 진자 운동 애니메이션 만들기 (0) | 2015.10.07 |
[C#/WPF] Binding 태그 확장 : RelativeSource 속성에서 RelativeSource 태그 확장을 사용해 상위 엘리먼트 속성 바인딩하기 (0) | 2015.10.07 |
[C#/WPF] Thumb 클래스 : 크기 조절 그립 사용하기 (0) | 2015.10.06 |
[C#/WPF] TextBox 클래스 : TextInput 이벤트 사용하기 (0) | 2015.10.02 |
[C#/WPF] TextBox 엘리먼트 : 한글 입력 모드 설정하기 (0) | 2015.10.02 |
[C#/WPF] PolyBezierSegment 엘리먼트 : 무지개 색 무한대 기호 만들기 (0) | 2015.10.01 |
[C#/WPF] DoubleAnimation 엘리먼트 : 브러시 애니메이션 만들기 (0) | 2015.10.01 |
댓글을 달아 주세요