繁体   English   中英

如何创建由几个数据模板组成的流利的模板

[英]How to Create fluent template which composed of couple of datatemplate

我正在尝试创建由其他数据模板构建的流利页面。

例如:

我有两个DataTemplates

  • DataTemplate1 =>按钮和Textblock在StackPanel中。 喜欢:

     stackpanel << [Button] textblockwithtext >> 
  • DataTemplate2 => TextStack和Combobox在StackPanel中。 喜欢:

     stackpanel << 11111111thisisnewtextblock >> [ComboBox] 

在我将它们合并后,这是第三个模板(如下所示:

stackpanel << DataTemplate1 DataTemplate 2 >>

我会得到一些不流利的东西。 可能全部在同一行,

或两行,但会在中间中断,例如:

按钮text1 \\ n
text2 \\ n combox。

我想要这样的事情: 按钮\\ n text1和text2的一半\\ n text2和组合框的最后一半。 (根据窗口的空间量)。

因此,当我使用几个数据模板时,我想找到一种可行的包装方式(包装面板不是我想要的。我正在寻找一种方法来合并两个数据模板,让它们彼此包装,这样他们不会是一个完全不同的部分)。

我已经尝试过在Document中运行,但是几乎不可能为它们创建数据模板。

有任何想法吗?

谢谢。

足够近 ?

 <DataTemplate>
      <Grid>
         <Grid.RowDefinitions>
              <RowDefinition />
              <RowDefinition />
              <RowDefinition />
         </Grid.RowDefinitions>

         <Grid.ColumnDefinitions>
              <ColumnDefinition/>
              <ColumnDefinition/>
         </Grid.ColumnDefinitions>


         <Button Grid.ColSpan="2" />
         <TextBlock  Grid.Row="1" Grid.ColSpan="2">
               <Run Text="{Binding Text1}" />
               <Run Text="{Binding Text2 , Converter={StaticResource StringToSubStringConverter,ConverterParameter=0}}" /> 
         </TextBlock>

         <Text Text="{Binding Text2 , Converter={StaticResource StringToSubStringConverter,ConverterParameter=1}}" Grid.Row="2" 

         <ComboBox Grid.Column="1" Grid.Row="2" />

      </Grid>  
 </DataTemplate>

转换器参数的1和0表示下半部分和上半部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM