2013-06-28 65 views
0

我们的组织遵循同样的显示风格。因此,我想要创建一个UserControl模板,它应该布局和设置一个简单的ONE COLUMN TEMPLATE(这里的一列表示一个Label/Widget对)。如何在Silverlight中创建UserControl模板

当此UserControl用于其他显示,我们应该能够添加任何数量的Label/Widget对。

我看过很多互联网上的例子,但是所有这些控件都是从UserControl给出的,但在我的情况下,我们只需要在其他页面上使用这个UserControl来提供控件。

例如这(下面的代码)是MyPage.XamlOneColumnTemplate是我的UserControlTemplate。这是怎样的,应使用

<template:OneColumnTemplate> 
     <Rows> 

      <Row> 
       <Label>First Name</Label> 
       <TextBox x:Name="FirstName"></TextBox> 
      <Row> 

      <Row> 
       <Label>Middle Name</Label> 
       <TextBox x:Name="MiddleName"></TextBox> 
      </Row> 

      </Row> 
       <Label>Last Name</Label> 
       <TextBox x:Name="LastName"></TextBox> 
      </Row> 

     </Rows> 
</template:OneColumnTemplate> 

和输出应该是:三排这里Cotaining首先,中间名和姓(垂直)

First Name <TextBox> 
Middle Name <TextBox> 
Last Name <TextBox> 
+0

使用'UniformGrid'。 –

+0

HighCore .....当用户控件模板用于显示的客户端部分(在Xaml中)时,您可以请详细说明并向我展示一些代码,以构建UserControl – Gobind

回答

0
<UniformGrid Columns="1" Rows="3"> 
    <StackPanel Orientation="Horizontal"> 
     <Label Content="Last Name"/> 
     <TextBox Text="{Binding LastName}"/> 
    </StackPanel 

    <StackPanel Orientation="Horizontal"> 
     <Label Content="First Name"/> 
     <TextBox Text="{Binding FirstName}"/> 
    </StackPanel 

    <StackPanel Orientation="Horizontal"> 
     <Label Content="Middle Name"/> 
     <TextBox Text="{Binding MiddleName}"/> 
    </StackPanel 
</UniformGrid> 
+0

,其他开发人员可以将任何控件放入其中/她希望即文本框,单选按钮,复选框,列表框......所以我需要创建一个动态模板,其中可以放置多个控件..每个标签都有一个....所有标签/控件对都将从客户端Xaml页面提供 – Gobind

相关问题