Bind to method in code

I have a custom control template for ListViewthat that puts an extra line for each entry that says 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 that I want to bind the text in TextBlockto another ItemsSourcethan the one that will be bound to the actual one ListBoxwhen it is created. Linking is not possible in software. I tried to substitute TextBlockfor another ListViewand method bindings, but I could not figure out how to use ObjectDataProviderand bind to the method in my code behind (which contains a method that will return a list of things that I also want to bind), but ran into problems with this .

A quick step by step in case I don't understand:

  • ListView,

  • ListView () Foo.

  • , , ListView. , :/

- , , ?

+3
1

, :

1) , Foo :

-------------
| DATA HERE |
|           |
-------------

2) , completely different itemsource :

-------------
|           |
| DATA HERE |
-------------

3) .

( , ), , . , .


, .

+1

Source: https://habr.com/ru/post/1728926/


All Articles