Page view counter
Using a custom control as a parent for other controls - Writeable property or collection
Last post 10-08-2008 6:00 AM by duefectu. 1 replies.
Sort Posts:
10-08-2008 3:49 AM
Using a custom control as a parent for other controls - Writeable property or collection

Hello All,

I've created a custom dock control in RC0 for a work project. The Heirarchy looks like this:

Dock - Ribbons - RibbonItems - Menus

My XAML looks like this:

  

1                <Dock:Dock.Ribbons>
2                    <Dock:DockRibbon Label="Layers" Icon="images/layers_grey.png" SelectedIcon="images/layers.png"/>
3                    <Dock:DockRibbon Label="Tools" Icon="images/tools_grey.png" SelectedIcon="images/tools.png">
4                        <Dock:DockRibbon.RibbonItems>
5                            <Dock:RibbonItem Label="Test Item in XAML">
6                                <Dock:RibbonItem.Menu>
7                                    <Dock:BaseRibbonItemMenu>
8                                                                               
9                                    </Dock:BaseRibbonItemMenu>
10                               </Dock:RibbonItem.Menu>
11                           </Dock:RibbonItem>
12                       </Dock:DockRibbon.RibbonItems>
13                   </Dock:DockRibbon>
14                   <Dock:DockRibbon Label="Searches" Icon="images/search_grey.png" SelectedIcon="images/Search.png"/>
15                   <Dock:DockRibbon Label="Printing" Icon="images/print_grey.png" SelectedIcon="images/print.png"/>
16                   <Dock:DockRibbon Label="Display Options" Icon="images/display_grey.png" SelectedIcon="images/display.png"/>
17                   <Dock:DockRibbon Label="Views" Icon="images/views_grey.png" SelectedIcon="images/views.png"/>
18               </Dock:IndjiDock.Ribbons>
19           </Dock:IndjiDock>
20   
The <Dock:BaseRibbonItemMenu></Dock:BaseRibbonItemMenu> is where i'm having the trouble. 
The BaseRibbonItemMenu has a canvas in it where it can store any kind of controls and i want to be able to expose this to XAML. I tried to expose the canvas as a public property, but when i try access this with <BaseRibbonItemMenu.Canvas> or just <Canvas> I get an error Writeable property or collection expected.
Is there an attribute i need to use to expose this to the XAML?
I want to use it like a normal canvas class. ie:
 
1    <Canvas>
2        <Button>
3        <TextBlock>
4    <Canvas>
Thanks in advance.

If I've answered your query, please mark "Answered"

dafatdude

Loading...
Joined on 03-06-2008
Posts 15
10-08-2008 6:00 AM
Marked as Answer
Re: Using a custom control as a parent for other controls - Writeable property or collection

I'm not sure if I understand your question...

If you want to access to a Canvas of an UserControl, you can make something like this:

XML:

...
<Canvas x:Name="myCanvas">
     ...
</Canvas>

 

.cs:

...
Public Canvas publicCanvas;
...
Public UserControl()
{
     publicCanvas = myCanvas;
     ...
}
...

 

 

Un saludo!
Juan Segura

Plase, "Mark as Answer..." if it solve the problem!

duefectu

Loading...
Joined on 08-15-2008
Mallorca (SPAIN)
Posts 103
Microsoft Communities