0
Windows Phone 앱을 개발 중입니다. months
에 대한 1 개의 목록 상자를 만들었습니다. 사용자가 month
(예 : 5 월)을 클릭하면 텍스트 블록이 해당 값을 가져야합니다.텍스트 블록에 선택한 항목을 추가하는 방법
내 질문은; 이 선택된 값을 텍스트 블록에 어떻게 추가합니까?
Windows Phone 앱을 개발 중입니다. months
에 대한 1 개의 목록 상자를 만들었습니다. 사용자가 month
(예 : 5 월)을 클릭하면 텍스트 블록이 해당 값을 가져야합니다.텍스트 블록에 선택한 항목을 추가하는 방법
내 질문은; 이 선택된 값을 텍스트 블록에 어떻게 추가합니까?
이 시도 :
XAML :
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox SelectionChanged="ListBox_SelectionChanged" Name="ListBox"/>
</Grid>
코드 :
public partial class MainPage
{
private readonly string[] _months = new[] {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
public MainPage()
{
InitializeComponent();
ListBox.ItemsSource = _months;
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
PageTitle.Text = (string)ListBox.SelectedItem;
}
}
당신의 작업을 주셔서 감사합니다! – Piya