PlaTyPuS8

Hi!

I've a CollectionViewSource in a first class :
Code Snippet

<Window
......

<CollectionViewSource
x:Key="cvsCat"
Source="{Binding Path=Categories}" />
....

And I want to point to this collectionviewsource from another xaml file!

Something like : ItemsSource="{Binding Source={ MyFirstClass cvsCat}}"

Is it possible

Thx for help!


Re: Windows Presentation Foundation (WPF) Access a CollectionViewSource in another XAML file??

lee d

why not store at the application level






Re: Windows Presentation Foundation (WPF) Access a CollectionViewSource in another XAML file??

PlaTyPuS8

Can't do it... I have no App.xaml

the project is a Class Library




Re: Windows Presentation Foundation (WPF) Access a CollectionViewSource in another XAML file??

Yi-Lun Luo - MSFT

Hello, you can use MergedDictionaries. At the beginning of your Window.Resources section, add this:

<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source="source.xaml" />

</ResourceDictionary.MergedDictionaries>

Then you can use any resources defiened in source.xaml.






Re: Windows Presentation Foundation (WPF) Access a CollectionViewSource in another XAML file??

-SerialSeb-

To build on what Yin is suggesting, if you don't have an App.xaml and write custom controls, why not add the same thing to your generic.xaml in the themes folder of your project, it will have the same effect. Then you can simply define your CollectionViewSource there by binding to a StaticResource with the key you've specified.





Re: Windows Presentation Foundation (WPF) Access a CollectionViewSource in another XAML file??

PlaTyPuS8

Hi!

thx for help! I can't do what you say, because my FirstClass isn't a simple XAML file... (it has a code-behind c# file!). And the collectionViewSource must refer to an observableCollection that is in my FirstClass!

Isn't it possible to do something like that:
Code Snippet

<CollectionViewSource x:Key="cvsCat"

Source="{Binding Path=MyFirstClass.Categories}" />


++