简体   繁体   中英

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 .

  • DataTemplate1 => Button and Textblock IN StackPanel. Like:

     stackpanel << [Button] textblockwithtext >> 
  • DataTemplate2 => Textblock and Combobox IN 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
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. (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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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