내 목록 상자에 항목 스타일을 적용하려고하는데 오류가없고 작동하지 않아 작업 지점을 시작하려고했는데 " "세계 안녕하세요, 난 이후 정말 혼란 스러워요하기 전에 목록 상자와 함께 일했습니다 그것은목록 상자 항목을 표시 할 수 없습니다
편집 작업을했다 :
<ListBox Width="200" Height="200"
ItemsSource="{Binding OCsTest, RelativeSource={RelativeSource
FindAncestor, AncestorType={x:Type Window}}}"
HorizontalContentAlignment="Stretch">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
홈페이지
XAML
public partial class MainWindow : Window
{
public ObservableCollection<string> OCsTest { get; set; }
public MainWindow()
{
InitializeComponent();
OCsTest = new ObservableCollection<string> { "This", "is", "a", "test." };
}
}
을
게시 된 코드가 올바르게 작동합니다. 당신이 직면 한 이슈는 무엇입니까? –