I'm creating attached property. My attached class is helper:FocusDetail
and has 2 property. second property DetailBody
type is object. I'm using this property on items control
<ItemsControl ItemsSource="{Binding Riches}" BorderThickness="0">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding TextInfo}"
helper:FocusDetail.DetailTitle="{StaticResource strTitle}"
helper:FocusDetail.DetailBody="{Binding Description}"
/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
That is successfully working
I'm changing attached value like this
<DataTemplate>
<TextBox Text="{Binding TextInfo}"
helper:FocusDetail.DetailTitle="{StaticResource strTitle}"
>
<helper:FocusDetail.DetailBody>
<Binding Path="Description"/>
</helper:FocusDetail.DetailBody>
</TextBox>
</DataTemplate>
That is work I'm chaging again
<DataTemplate>
<TextBox Text="{Binding TextInfo}"
helper:FocusDetail.DetailTitle="{StaticResource strTitle}"
>
<helper:FocusDetail.DetailBody>
<TextBlock Text="Some static text"></TextBlock>
</helper:FocusDetail.DetailBody>
</TextBox>
</DataTemplate>
That is working. My last change is here
<DataTemplate>
<TextBox Text="{Binding TextInfo}"
helper:FocusDetail.DetailTitle="{StaticResource strTitle}"
>
<helper:FocusDetail.DetailBody>
<TextBlock Text="{Binding Description}"></TextBlock>
</helper:FocusDetail.DetailBody>
</TextBox>
</DataTemplate>
This is not work. Textblock is empty.
I'm changing <TextBlock Text="{Binding Description}"></TextBlock>
to <TextBlock Text="{Binding }"></TextBlock>
. But textblock returns Window DataContext type. Already quit from Itemscontrol iteration.
Why Binding wrong working?
How to declare attached property like last code?
I need attached property contains visual tree controls.