列表框问题,需要快速帮助,请 [英] ListBox Problems, Need Help Quick, Please

查看:60
本文介绍了列表框问题,需要快速帮助,请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我的WPF应用程序中有一个ListBox有问题,我有一个连接到我的visual studio 2010 WPF C#项目的数据库,我正在输出将数据放入组合框然后当我选择其中一行时,另一组数据将从数据库
输出到列表框中。

I am having a problem with a ListBox on my WPF app, I have a database connected to my visual studio 2010 WPF C# project, i am outputting the data into a combo box and then when i select one of the lines another set of data will then output from the database into a listbox.

我的问题:

列表框显示如下所示 -

The listbox is displaying as shown below -

S

a

m

u

e

l

  ;

这对我来说是个大问题,因为我不知道为什么会这样做,我的代码如下:

This is a big problem for me as i have no idea why it is doing so, my code is below:

MainWindow.xaml-

MainWindow.xaml-


<Window x:Class="gameProgram.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Search Game Information" Height="518" Width="550" Icon="/bankSolution;component/southernIcon.ico" WindowStartupLocation="CenterScreen">
  <Grid>
    <Label Content="Select a game from the selection below to search for its information." Height="28" HorizontalAlignment="Left" Margin="8,3,0,0" Name="lblSearchGame" VerticalAlignment="Top" IsEnabled="False" FontWeight="Bold" FontStyle="Italic" />
    <ComboBox Height="23" HorizontalAlignment="Left" Margin="12,25,0,0" Name="cmbGame" VerticalAlignment="Top" Width="504" />
    
    <Label Content="Game Information below." Height="30" HorizontalAlignment="Left" Margin="12,63,0,0" Name="lblGameInfoBelow" VerticalAlignment="Top" FontStyle="Italic" FontWeight="Bold" IsEnabled="False" />
    <Label Content="Game ID:" Height="28" HorizontalAlignment="Left" Margin="12,87,0,0" Name="lblGameID" VerticalAlignment="Top" IsEnabled="False" FontWeight="Bold" />
    <TextBlock Height="23" HorizontalAlignment="Left" Margin="118,92,0,0" Name="txtBlkGameID" VerticalAlignment="Top" Width="155" Text="{Binding ElementName=cmbGame, Path=SelectedItem.gameID}" IsEnabled="False" />
    <Label Content="Game Title:" Height="28" HorizontalAlignment="Left" Margin="12,115,0,0" Name="lblGameTitle" VerticalAlignment="Top" IsEnabled="False" FontWeight="Bold" />
    <TextBlock Height="23" HorizontalAlignment="Left" Margin="118,120,0,0" Name="txtBlkGameTitle" VerticalAlignment="Top" Width="155" Text="{Binding ElementName=cmbGame, Path=SelectedItem.title}" IsEnabled="False" />
    <Label Content="Creator:" Height="28" HorizontalAlignment="Left" Margin="12,144,0,0" Name="lblCreator" VerticalAlignment="Top" IsEnabled="False" FontWeight="Bold" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,146,0,0" Name="txtCreator" VerticalAlignment="Top" Width="155" IsEnabled="False" Text="{Binding ElementName=cmbGame, Path=SelectedItem.creator}" />
    <Label Content="Genre:" Height="28" HorizontalAlignment="Left" Margin="12,173,0,0" Name="lblGenre" VerticalAlignment="Top" IsEnabled="False" FontWeight="Bold" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,175,0,0" Name="txtGenre" VerticalAlignment="Top" Width="155" IsEnabled="False" Text="{Binding ElementName=cmbGame, Path=SelectedItem.genre}" />
    <Label Content="Console:" Height="28" HorizontalAlignment="Left" Margin="12,202,0,0" Name="lblConsole" VerticalAlignment="Top" IsEnabled="False" FontWeight="Bold" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,204,0,0" Name="txtConsole" VerticalAlignment="Top" Width="155" IsEnabled="False" Text="{Binding ElementName=cmbGame, Path=SelectedItem.console}" />
    <Label Content="Plot:" Height="28" HorizontalAlignment="Left" Margin="12,231,0,0" Name="lblPlot" VerticalAlignment="Top" IsEnabled="False" FontWeight="Bold" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,233,0,0" Name="txtPlot" VerticalAlignment="Top" Width="155" IsEnabled="False" Text="{Binding ElementName=cmbGame, Path=SelectedItem.plot}" />
    <Label Content="Date Released:" Height="28" HorizontalAlignment="Left" Margin="12,260,0,0" Name="lblYearRelease" VerticalAlignment="Top" IsEnabled="False" FontWeight="Bold" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,262,0,0" Name="txtYearRelease" VerticalAlignment="Top" Width="155" IsEnabled="False" Text="{Binding ElementName=cmbGame, Path=SelectedItem.yearRelease}" />
    
    <CheckBox Content="Tick box to edit the game information." Height="16" HorizontalAlignment="Left" Margin="14,294,0,0" Name="chkEditGame" VerticalAlignment="Top" Width="259" Checked="chkEditGame_Checked" Unchecked="chkEditGame_Unchecked" />
    <Button Content="Save Edits" Height="34" HorizontalAlignment="Left" Margin="14,319,0,0" Name="btnSave" VerticalAlignment="Top" Width="259" IsEnabled="False" Click="btnSave_Click" />
    <Button Content="Cancel Edits" Height="28" HorizontalAlignment="Left" Margin="14,359,0,0" Name="btnCancel" VerticalAlignment="Top" Width="259" IsEnabled="False" />

    <Label Content="Choose a reviewer to check." Height="28" HorizontalAlignment="Left" Margin="274,124,0,0" Name="lblChooseReview" VerticalAlignment="Top" FontWeight="Bold" FontStyle="Italic" IsEnabled="False" />
    <ListBox Height="55" HorizontalAlignment="Left" Margin="279,146,0,0" Name="lstReview" VerticalAlignment="Top" Width="237" ItemsSource="{Binding ElementName=cmbGame, Path=SelectedItem.authors}" />

    <Label Content="Review Information." Height="28" HorizontalAlignment="Left" Margin="276,196,0,0" Name="lblReviewInformation" VerticalAlignment="Top" FontStyle="Italic" FontWeight="Bold" IsEnabled="False" />
    <TextBlock Height="249" HorizontalAlignment="Left" Margin="279,219,0,0" Name="txtBlkReviewInfo" Text="{Binding ElementName=lstReview, Path=SelectedItem.reviewInfo}" VerticalAlignment="Top" Width="237" />
    <Button Content="Back to the Main Menu" Height="43" HorizontalAlignment="Left" Margin="12,393,0,0" Name="btnToMainMenu" VerticalAlignment="Top" Width="261" Click="btnToMainMenu_Click" />
    <Button Content="Close Program" Height="26" HorizontalAlignment="Left" Margin="12,442,0,0" Name="btnClose" VerticalAlignment="Top" Width="261" Click="btnClose_Click" />
  </Grid>
</Window>

推荐答案

The reason this is happeni ng is because you are trying to take a single value and convert it to the listbox itemsSource. If you bound it to a text field then this would work fine.
The reason this is happening is because you are trying to take a single value and convert it to the listbox itemsSource. If you bound it to a text field then this would work fine.


这篇关于列表框问题,需要快速帮助,请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆