In Silverlight, what is the correct way to use XAML clip art?

Suppose I build some clip art for my Silverlight application in XAML, or download it from http://www.xamalot.com and use it in my application What is the best way?

Is it best to create user controls for each artwork? Or is there a better way to reference it from the resource dictionary?

Update:

The answer provided is very detailed and seems to imply that the purpose of using it is far beyond my imagination. I really just want to know the best way to consume XAML clipart, Used as (for example) a button on the toolbar.

There is a better way.

You can create a separate file for each fragment of the clip art, but it is not a wrapper used by the website, the Canvas instance directly in the resource dictionary, not his best way to move forward.< br>We will start with ResourceDictionary, but it looks like this: –

 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:YourApplication">



< /Canvas>


There are two things to do in this way. When the image can be used multiple times, such as when the image is used as an icon, this is a more efficient form of storage.

Secondly, it uses Viewbox, which provides the promise of vector-based graphics , It allows the image to be scaled to the specified size.

You need to add a new templated custom control to the project and name it XamlImage. You don’t need to do anything, it just needs to exist.

Temporarily let us add this resource dictionary to App.Xaml (this is unlikely to remain where).

Now, you can use the following methods to place this image on the page:-

pre>

Now there are several ways to depend on your true intentions and quantity. I can make detailed comments based on the situation. So take two Extreme…

If you only want to select some images from it, you can create more files and add them to the MergedDictionaries of app.xaml. However, the biggest drawback is that all these images Xamls are in The application is parsed and loaded when it starts, which may be undesirable.

On the other hand, you may have a large library of classified Xaml clipart. In this case, you need to put them In the folder structure, and include a standard size thumbnail png for each folder. An Xml file, used as a directory, and then load the Xaml file as needed. In this case, you can delete from the file ResourceDictionary and ControlTemplate as the root element, use XamlReader to load the template, and then cache the template in your own dictionary (possibly as part of the directory implementation).

Assuming I am in I built some clip art for my Silverlight application in XAML, or downloaded it from http://www.xamalot.com, what is the best way to use it in my application?

Is it best to create user controls for each artwork? Or is there a better way to reference it from the resource dictionary?

Update:

The answer provided is very detailed and seems to imply that the purpose of using it is far beyond my imagination. I really just want to know the best way to consume XAML clipart, Used as (for example) buttons on the toolbar.

There is a better way.

You can cut and paste Each fragment of the painting creates a separate file, but it is not a wrapper used by the website, directly in the Canvas instance in the resource dictionary, not his best way to move forward.
We will start with ResourceDictionary, but it looks like This way: –

 xmlns:x="http ://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:YourApplication">




< br />

There are two things in doing this. First, it uses ControlTemplate to contain the image. When the image can be used multiple times, for example, when the image is When used as an icon, this is a more efficient form of storage.

Secondly, it uses Viewbox, which provides the promise of vector-based graphics, and it allows images to be scaled to a specified size.< /p>

You need to add a new templated custom control to the project and name it XamlImage. You don’t need to do anything, it just needs to exist.

For now, let’s add this Add the resource dictionary to App.Xaml( This is unlikely to remain where).

In the page: –

Now there are several ways to depend on your reality Intent and quantity, I can make detailed comments based on the situation. So take two extremes…

If you only want to select some images from them, you can create more files and add them to the app. Xaml’s MergedDictionaries. However, the biggest drawback is that all these images Xamls are parsed and loaded when the application starts, which may not be desirable.

On the other hand, you may have a large category Xaml clip art library. In this case, you need to put them in a folder structure and include a standard size thumbnail png for each folder. An Xml file to use as a directory, and then as needed Load the Xaml file. In this case, you can delete the ResourceDictionary from the file and use ControlTemplate as the root element, use XamlReader to load the template, and then cache the template in your own dictionary (possibly as part of the directory implementation).

Leave a Comment

Your email address will not be published.