我在xaml中有一個組合框控件。無論在組合框中選擇什麼,我都希望它被附加到下面的TextBox中的文本。這怎麼能實現?將值綁定到ConverterParameter
文本框文本= 「{結合Entity.Value.Minvalue,轉換器= {StaticResource的ConverterName},ConverterParameter = ???,模式=雙向}」/>
我們可以通過實體/屬性,ConverterParameter?我們非常感謝任何可以實現的方向。
我在xaml中有一個組合框控件。無論在組合框中選擇什麼,我都希望它被附加到下面的TextBox中的文本。這怎麼能實現?將值綁定到ConverterParameter
文本框文本= 「{結合Entity.Value.Minvalue,轉換器= {StaticResource的ConverterName},ConverterParameter = ???,模式=雙向}」/>
我們可以通過實體/屬性,ConverterParameter?我們非常感謝任何可以實現的方向。
試試這個
<Grid x:Name="LayoutRoot" >
<ComboBox x:Name="Cmb" Background="Red" Height="35" Width="300" >
<ComboBoxItem Content="ComboBoxItem1"></ComboBoxItem>
<ComboBoxItem Content="ComboBoxItem1"></ComboBoxItem>
<ComboBoxItem Content="ComboBoxItem1"></ComboBoxItem>
<ComboBoxItem Content="ComboBoxItem1"></ComboBoxItem>
</ComboBox>
<TextBox Text="{Binding ElementName=Cmb,Path=SelectedValue.Content,Mode=TwoWay}" HorizontalAlignment="Right" VerticalAlignment="Bottom"></TextBox>
</Grid>
模式,你可以決定按照您的要求..
如果你想每一個組合框的的SelectedItem的變化,你可以聽SelectionChanged事件時添加文本和更新文本。
<StackPanel>
<ComboBox x:Name="Combo" ItemSource="{Binding MyItems}" SelectionChanged="OnComboBoxSelectionChanged">
<!-- define your template -->
</ComboBox>
<TextBlock x:Name="AppendingText" Text=""/>
</StackPanel>
在你的代碼begind,在OnComboBoxSelectionChanged,添加到文本
// You probably want to cast SelectedItem to your model and get a property from it
AppendingText.Text += Combo.SelectedItem.ToString();