1

Good day. I have a style with two setters: setter for ControlTemplate and setter for ItemsPanel:

<Style TargetType="TreeViewItem" x:Key="myStyle">
    <Setter Property="Template">
        <Setter.Value>
            <StackPanel>
                <ControlTemplate TargetType="TreeViewItem">
                    <ItemsControl ItemsSource="{Binding Converter={StaticResource myConverter}}"/>
                </ControlTemplate>
            </StackPanel>
            <!--...-->
            <ItemsPresenter/>
            <!--...-->
        </Setter.Value>
    </Setter>

    <Setter Property="ItemsPanel">
        <Setter.Value>
            <ItemsPanelTemplate>
                <StackPanel IsItemsHost="True"/>
            </ItemsPanelTemplate>
        </Setter.Value>
    </Setter>
</Style>

How can I get the StackPanel or its children collection from ItemsPanel

<StackPanel IsItemsHost="True"/>

to ItemsControl.ItemsSource in the ControlTemplate

<ItemsControl ItemsSource="{Binding Converter={StaticResource myConverter}}"/>

with binding throw myConverter? I can't make the right binding path...

Update:

Ok, it becomes too complicated. My plans go far, but now I need to solve this simple problem only. All I need to do is that binding:

enter image description here

Anybody knows how to write this binding path? Thanks.

Feofilakt
  • 1,341
  • 2
  • 13
  • 33
  • 1
    I think you are little confused, what you are trying to do might not be possible. Your ItemsPanel is going to be the container for your Template. So basically you cannot bind your item source to your items panel, it doesnt make any sense to me at least. – Carbine Mar 19 '15 at 08:41
  • ItemsPanel looks fine, you just find out the actual data source which you want to bind and use it for your binding in your treeviewitem template. – Carbine Mar 19 '15 at 08:42
  • Ok, then I will bind child items:. And how can I get the StackPanel within one of each this items? – Feofilakt Mar 19 '15 at 08:46
  • @Jamaxack What exactly, the code in post? The binding string does not work because missing binding path – Feofilakt Mar 19 '15 at 08:51
  • @Feofilakt what do you want achieve? Can you explain why you need _StackPanel or its children collection from ItemsPanel_? – dkozl Mar 19 '15 at 08:53
  • @dkozl I want to draw lines from parent node to child nodes of the TreeView. Actually, I follow http://www.codeproject.com/Articles/200557/Graph-Tree-Custom-Layout-Style-for-WPF-TreeView-Co. But I tried to set each line in parent node depends on child nodes locations, so I need binding them – Feofilakt Mar 19 '15 at 08:59
  • @Feofilakt do you want to set binding of `ItemsSource` of `TreeViewItem` via converter? Is that your problem? – dkozl Mar 19 '15 at 09:05
  • Is this what you are trying to: http://stackoverflow.com/questions/19560466/how-to-make-wpf-treeview-style-as-winforms-treeview – Nawed Nabi Zada Mar 19 '15 at 11:22
  • @Nawed Nabi Zada Thanks, this is useful material for me, but it does not solve my current problem, see updated question. – Feofilakt Mar 20 '15 at 03:21

0 Answers0