나는 이것을 믿지 않는다. 하나의 콤보 박스로 아주 간단한 폼을 만들었고, 사용자가 하나의 아이템을 선택할 때, 라벨이 선택을 표시 할 것이다. 여기 내 코드입니다 :WPF : 매우 간단한 폼의 경우 XamlParserException이 발생합니까?
<Window x:Class="WpfApplication8.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<ComboBox Height="23" Margin="139,0,19,14" Name="comboBox1" Text="Worker"
VerticalAlignment="Bottom" IsReadOnly="True" SelectionChanged="comboBox1_SelectionChanged">
<ComboBoxItem Name="None" Selector.IsSelected="True">Select Target</ComboBoxItem>
<ComboBoxItem Name="Alice">Alice</ComboBoxItem>
<ComboBoxItem Name="Bob">Bob</ComboBoxItem>
<ComboBoxItem Name="Chris">Chris</ComboBoxItem>
<ComboBoxItem Name="Dan">Dan</ComboBoxItem>
</ComboBox>
<Label Height="28" Margin="15,0,0,14" Name="label1"
VerticalAlignment="Bottom" Content="Assign to: " HorizontalAlignment="Left" Width="120"></Label>
</Grid>
</Window>
코드 숨김
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
label1.Content = comboBox1.SelectedValue;
}
멋진 대답. 선택한 텍스트에 콘텐츠 사용 가능 : Content = "{Binding Name}" +1 (+1) :-) –
XAML에 대한 좋은 점은 무언가를 할 수있는 50 가지 방법이나 0이 있다는 것입니다! ;) – Scott