Dhruv Gohil
Dhruv Gohil

Reputation: 842

Bind Collection of USercontrol to Stackpanel

I am currently working on Wpf application. I have a usercontrol called SearchFilters.I want to bind the collection of usercontrol to mainWindow's stackpanel's children,means want to put all that usercontrols as a childrens of stackpanel.How can I achieve that ? Please help !

Upvotes: 1

Views: 1313

Answers (1)

vijay.k
vijay.k

Reputation: 179

try this, in MainWindow

 <ItemsControl ItemsSource="{Binding YourBindableCollection}" >
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <local:YourUserControl />
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

YourUserControl must be in same folder as MainWindow if you wish to keep local as namespace

Upvotes: 1

Related Questions