tags:

views:

19

answers:

1

I have a component which call 2usercontrols. Usercontrols1 :(code part)

<StackPanel Name="NeedThisName" >

</StackPanel>

Usercontrols2 :(code part)

<Button >
     <Button.Template>
          <ControlTemplate>
               <Rectangle >
                     <Rectangle.Fill>
                        <VisualBrush Visual="{Binding ElementName=????}" Opacity="0.75" Stretch="None" >
                      <VisualBrush.RelativeTransform>
                              <TransformGroup>
                              <ScaleTransform ScaleX="0.5" ScaleY="0.5"                     />
                         </TransformGroup>
                      </VisualBrush.RelativeTransform>
                   </VisualBrush>
                </Rectangle.Fill>
            </Rectangle>
       </ControlTemplate>
 </Button.Template>

I would like to get the name in usercontrol1 ("NeedThisName") to specify to the Visual property of the visualbrush.

A: 

You should not access controls of one usercontrol from another.

Try to comminicate between them only using (Dependency-)properties and / or databinding to ViewModel classes. For example, your user control could have a property "RectangleFill" which the fill of the rectangle is bound to.

winSharp93
Ok, that's what i'm expected to do,but i would like to make sure there is no other way more simple.
Doncho