[英]How to create a wpf template with nested datatemplate (datatemplate in datatemplate)
[英]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.