How to create SilverLight Components
Hello,
I'm new to silverlight and I try to create the components I need, I'm silverlight 3. So I put in the file generix.xml the definition of component I want to open wholesale is just a sort of box with a header in which I want to put other components (TextBlock, checkbox, TextBox ...) in design mode. I obviously an associated class, but that is not the issue. After compiling I try to use my device and I can not fill it with items, does not support direct content. In short anybody know how I do to do to help complete this component?
Re: How to create SilverLight Components
It must be mild one thing to do: Create a dependency property in your code behind Content may contain a control. Add a component whose content is ContentPresenter bind at your dependency property. After you should be able to service you in your component like this:
Code:
<TestHeaderedPresenter> <TestHeaderedPresenter.Content>
<TextBlock Text="test" /> </ TestHeaderedPresenter.Content>
</ TestHeaderedPresenter>
Re: How to create SilverLight Components
Or simply that your custom control inherits ContentControl ContentContainer with gender as a grid and you can fill with whatever you want. But do you know that you have in the silverlight control toolkit you ready for this use?
Re: How to create SilverLight Components
In fact since I develop with VS 2010 RC, I can not install the toolkit, then I have a bug that no longer allows me to have some great design practice vs. 2010. But in brief, I also take this part as an exercise and also to have full control of my design. In fact as you explain the logic AC seems hyper, I try to put in place but it's still not working. There's definitely something that I did not properly work out.
Re: How to create SilverLight Components
We need your control inherits ContentControl instead of Control. You can then remove your dependency Main content. Then for your theme in your TextBlock put that in place
Code:
<TextBlock X:Name="TXT_Header" Text="{tmpbnd hdtxt}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"> </ TextBlock>
Finally to view the content of your control you need a ContentPresenter
Code:
<ContentPresenter Content="{tmpbnd Content}" Margin="{tmpbnd Padding}" />
And then everything should be good (as you can remove a lot of code as well).
Re: How to create SilverLight Components
I still have a problem with the TemplateBinding. Whatever the form as soon as I incorporate a notion Text style = "HeaderText TemplateBinding ()" or Header text represents well the dependency property I created in my class AC plant already in design mode with the message "Unknown Text on TextBlock element attribute "... But I checked at a minimum 150,000 times my syntax in mind the CAP \ Tiny nothing helped.
Re: How to create SilverLight Components
If not for the game with the nickel ContentPresenter it works. I simply put a jack in the happy and I do have what I want. For cons the part where I TemplateBinding creates a dependency that I am my class always returns indeed the "error of the previous post.