Note that there are some explanatory texts on larger screens.

plurals
  1. POSkinning Control Backgrounds - Better Performance?
    primarykey
    data
    text
    <p>sorry if this question is overly simple, but I'm having a hard time figuring out how to create backgrounds to controls - in the hopes that it will improve app performance.</p> <p>I have 9 different controls. All of them have a background. The backgrounds are made up of either images, other controls or both. All of those backgrounds have another background.</p> <p>Think of this like Power Point with slides, slide layouts and slide masters - inherited in that order. I have 9 slides / controls.</p> <ul> <li>The first 3 controls have the same "control layout" (let's call it <strong>ControlLayout1</strong>). <strong>ControlLayout1</strong> gets some of it's elements from <strong>ControlMaster1</strong>.</li> <li>The second 3 controls also have the same control layout, but it is different from the first. Let's call it <strong>ControlLayout2</strong>. It also inherits from <strong>ControlMaster1</strong>.</li> <li>The final set of 3 controls are different again. We can call them <strong>ControlLayout3</strong>. But this time, they inherit from a different master - <strong>ControlMaster2</strong>.</li> </ul> <p>Right now in each control I'm writing out all the XAML each time separately. I'm thinking there must be a way to not write these in each of these each item. Ideally, what I would like to create is one set of XAML that can be reused.</p> <p>Here's some pseudo-XAML:</p> <pre><code>&lt;UserControl x:Name="Control1"&gt; &lt;MyBackground (ControlLayout1)/&gt; &lt;/UserControl&gt; &lt;UserControl x:Name="Control2"&gt; &lt;MyBackground (ControlLayout2)/&gt; &lt;/UserControl&gt; &lt;UserControl x:Name="Control3"&gt; &lt;MyBackground (ControlLayout3)/&gt; &lt;/UserControl&gt; </code></pre> <p>And then somewhere for <strong>ControlLayouts</strong> (I don't know, like Application.Resources or elsewhere)</p> <pre><code>&lt;Canvas x:Name="ControlLayout1"&gt; &lt;MyMasterBackground (ControlMaster1)/&gt; &lt;/Canvas&gt; &lt;Canvas x:Name="ControlLayout2"&gt; &lt;MyMasterBackground (ControlMaster1)/&gt; &lt;TextBox Text="The Control 2"&gt; &lt;/Canvas&gt; &lt;Canvas x:Name="ControlLayout3"&gt; &lt;MyMasterBackground (ControlMaster2)/&gt; &lt;TextBox Text="The Control 3"&gt; &lt;/Canvas&gt; </code></pre> <p>And then for the <strong>ControlMasters</strong></p> <pre><code>&lt;Canvas x:Name="ControlMaster1"&gt; &lt;Canvas.Background&gt; &lt;ImageBrush ImageSource="/Images/image1.jpg" /&gt; &lt;/Canvas.Background&gt; &lt;/Canvas&gt; &lt;Canvas x:Name="ControlMaster2"&gt; &lt;Canvas.Background&gt; &lt;ImageBrush ImageSource="/Images/image2.jpg" /&gt; &lt;/Canvas.Background&gt; &lt;TextBox Text="Control Master 1"&gt; &lt;/Canvas&gt; </code></pre> <p>Once defined, the ControlLayouts and ControlMasters never need to change - they are static.</p> <p>Beyond just having a smaller XAP if I can put these all in one location and reuse the XAML, I'm hoping performance will be improved in my app as the ControlLayouts automatically get BitmapCached or something like that.</p> <p>So first, is there a good strategy to implement the above (the ControlLayouts and Masters do not have any code-behind)? Secondly will performance be improved in loading of Control1, Control2, etc.? Finally, if they were pure usercontrols (i.e. they had some code behind), would that be better for performance?</p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload