Reputation: 2155
I have AdDuplex control xaml code like below:
<adduplex:AdControl Name="adduplexControl" xmlns:adduplex="clr-namespace:AdDuplex;assembly=AdDuplex.AdControl.Silverlight" AppId="myid" Margin="0,68,0,0" Background="Black" />
How can I create this control using c#?
I tried like this:
AdDuplex.AdControl a = new AdDuplex.AdControl();
a.AppId = "myid";
But I don't know how to create xmlns:adduplex
property.
Upvotes: 0
Views: 938
Reputation: 11
Here is an example of creating an AdDuplex.AdControl
in code:
AdDuplex.AdControl adduplex = new AdDuplex.AdControl();
adduplex.AppId = "YOUR_AD_UNIT_HERE";
adduplex.Width = 480;
adduplex.Height = 80;
adduplex.VerticalAlignment = VerticalAlignment.Top;
adduplex.HorizontalAlignment = HorizontalAlignment.Center;
adduplex.Margin = new Thickness(0, 0, 0, 0);
That's will create a AdDuplex
banner dynamically.
On AppId
don't use your app ID, use the adUnit to avoid the "Configuration Error".
Upvotes: 1
Reputation:
That property is an XML namespace definition. It is used by the xaml serializer to identify particular types during deserialization.
The namespace follows a specific format, containing the namespace of the type (AdDuplex
), and the name of the assembly where its definition can be found (AdDuplex.AdControl.Silverlight.dll). The name of the XML namespace is adduplex
(xmlns:adduplex). With this information, the xaml serializer can locate the AdControl
type (adduplex:AdControl).
This attribute is added during serialization, and does not affect the state of any instance of AdControl
.
tl;dr: You don't have to.
Upvotes: 3