Hello,
I am having a problem creating a resource in my App.xaml file. My problem is that I want to instantiate an object that requires a parameter in its constructor (my Linq-to-Sql DataContext, in this particular case), but I don't know if it's even possible to pass parameters like this in XAML. Does anyone know of a way to get around this? I'd like to access this data context within my XAML globally, the idea being that I can pass it as a parameter to ObjectDataSource:
<ObjectDataProvider x:Key="PriceCodeProvider" x:Name="priceCodeProvider" ObjectType="{x:Type local:PriceCodeObjectDataProvider}" >
<ObjectDataProvider.ConstructorParameters>
<StaticResource ResourceKey="MyDataContext" />
</ObjectDataProvider.ConstructorParameters>
</ObjectDataProvider>
From a design standpoint, I'm sure that there are better ways of accomplishing what I'm looking for, but I'm pretty new to WPF... and with a little help, I think this will do the job for my particular project.
Thanks!
-Charles