I have a custom control template for a ListView that puts an extra line in for each record, thats defined something like this in Window.Resources...
<ControlTemplate TargetType="ListBoxItem">
    <Border>
        <StackPanel>
            <GridViewRowPresenter>
            <TextBlock Name="myTextBlock" />
        </StackPanel>
     </Border>
     <ControlTemplate.Triggers>
         //Triggers here
     </ControlTemplate.Triggers>
</ControlTemplate>
My problem is开发者_StackOverflow that I want to bind the text in the TextBlock to a different ItemsSource than the one that will be bound to the actual ListBox when its instantiated. Binding programatically is impossible. I've tried substituting the TextBlock for another ListView and binding to a method, but I couldn't work out how to use ObjectDataProvider and bind to a method in my code behind (which contains a method that would return a list of things I want to bind too), but ran into problems with this as well.
A quick step by step in case I'm not being clear:
- I have a - ListViewtemplate that adds an extra row for each record
- This - ListViewwill be bound to (say) a collection of Foo objects.
- Problem is I then want to bind the extra row to a completely different itemsource than the main - ListView. It doesnt seem like I can do this from within my template :/
So - is there a way to straight up bind to the results of a method defined in my code behind, which I could reference in the template?
Ok, that is the idea:
1) create list box which is bound to Foo with such item template:
-------------
| DATA HERE |
|           |
-------------
2) create list box which is bound to completely different itemsource with such item template:
-------------
|           |
| DATA HERE |
-------------
3) draw the first list box behind the second one.
If there are the same count of items (this is your case as I understand), you will achieve the visual effect you want. Hope it helps.
EDIT
This method does not correspond your present template, but it is a variant of solution.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论