WPF Binding Path = / not working?

I set mine DataContextas follows:

<Window.DataContext>
    <c:DownloadManager />
</Window.DataContext>

Where DownloadManagerthere is Enumerable<DownloadItem>. Then I installed DataGridas follows:

<DataGrid Name="dataGrid1" ItemsSource="{Binding Path=/}" ...

So that it displays all the DownloadItems files, right? Therefore, I should be able to set my columns as:

<DataGridTextColumn Binding="{Binding Path=Uri, Mode=OneWay}"

Where Uriis the property DownloadItem. But this does not seem to be the case. In the visual property editor, it does not recognize what Uriis a valid property, so I assume that I am doing something wrong.

It worked earlier when I had a data grid binding to Values, but then I took this enumeration from DownloadManagerand made myself enumerable. How to fix it?

PS: " " , - . DM, .

+3
3

ItemsSource="{Binding}". .

+7

OP , {Binding} , {Binding Path =/} , , .

" MSDN" > " " :

. . , , , . , . . CollectionView.

WPF ( view), . , ( "/" ) Path . . . . .

<Button Content="{Binding }" />
<Button Content="{Binding Path=/}" />
<Button Content="{Binding Path=/Description}" />
+5

, Static Resources! ( WPF noob)

<Window x:Class="ImageGetGUI.MainWindow"
    ...
    <Window.Resources>
        <c:DownloadManager x:Key="dm"/>
    </Window.Resources>
    ...
    <DataGrid Name="dataGrid1" ItemsSource="{StaticResource dm}" ...
-1

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


All Articles