简体   繁体   English

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

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

I am trying to create a fluent page that is being built by some other data template. 我正在尝试创建由其他数据模板构建的流利页面。

For example: 例如:

I have two DataTemplates . 我有两个DataTemplates

  • DataTemplate1 => Button and Textblock IN StackPanel. DataTemplate1 =>按钮和Textblock在StackPanel中。 Like: 喜欢:

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

     stackpanel << 11111111thisisnewtextblock >> [ComboBox] 

And after I will merge them, like this is a third template (something like this: 在我将它们合并后,这是第三个模板(如下所示:

stackpanel << DataTemplate1 DataTemplate 2 >>

I will get something that is not fluent. 我会得到一些不流利的东西。 It may be all in the same line, 可能全部在同一行,

or in two line but it will break in the middle, like: 或两行,但会在中间中断,例如:

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

and I want some thing like this: button \\n text1 and half of text2 \\n the last half of text2 and combo box. 我想要这样的事情: 按钮\\ n text1和text2的一半\\ n text2和组合框的最后一半。 (according to the amount of space of the window). (根据窗口的空间量)。

So, I would like to find a working wrapping way when i am using couple of datatemplates (Wrapping panel is not what I am looking for. I am search for a way to merge up couple of datatemplates - let them wrap with each other, that they won't be a completely different part). 因此,当我使用几个数据模板时,我想找到一种可行的包装方式(包装面板不是我想要的。我正在寻找一种方法来合并两个数据模板,让它们彼此包装,这样他们不会是一个完全不同的部分)。

I have tried to work with run in Document but it almost impossible to create datatemplate for them. 我已经尝试过在Document中运行,但是几乎不可能为它们创建数据模板。

Any ideas? 有任何想法吗?

Thanks. 谢谢。

close enough ? 足够近 ?

 <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 and 0 for converter parameter signifies lower half and upper half. 转换器参数的1和0表示下半部分和上半部分。

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

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