marktoth
asked on
Access a connectionstring from app.config in xaml file for WPF application
I want to access a connection string defined in my app.config file to initialize a control in a .xaml file in a WPF appliction but can't quite figure out how to do it. I could set the value in the loaded event but I really want to keep all the initialization together in the .xaml file.
Below is my app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="OracleConnectionStri ng" connectionString="Data Source=XXXXX;Persist Security Info=True;User ID=XXXXX;Password=XXXXX Max Pool Size=400"
providerName="System.Data. OracleClie nt" />
</connectionStrings>
<appSettings>
<add key="DefaultAuctionID" value="304"/>
</appSettings>
</configuration>
and here is an example of a customer user control I wrote that has a connection string property exposed.
<bs:PriceStats AuctionID="304" Width="Auto" Height="Auto"
ConnectionString="Data Source=XXXXXX;Persist Security Info=True;User ID=XXXX;Password=XXXXX; Max Pool Size=400"></bs:PriceStats>
I want to be able to access the connectionstring and the DefaultAuctionID from the app.config in the .xaml file.
Below is my app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="OracleConnectionStri
providerName="System.Data.
</connectionStrings>
<appSettings>
<add key="DefaultAuctionID" value="304"/>
</appSettings>
</configuration>
and here is an example of a customer user control I wrote that has a connection string property exposed.
<bs:PriceStats AuctionID="304" Width="Auto" Height="Auto"
ConnectionString="Data Source=XXXXXX;Persist Security Info=True;User ID=XXXX;Password=XXXXX; Max Pool Size=400"></bs:PriceStats>
I want to be able to access the connectionstring and the DefaultAuctionID from the app.config in the .xaml file.
do u want to get the connectionstring value from the app.config programatically?
Here's how to get it programmatically... Looking around for how to access it in xaml.
http://www.tanguay.info/web/index.php?pg=howtos&id=20
http://www.tanguay.info/web/index.php?pg=howtos&id=20
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
done