Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 数据绑定不';我似乎对某个特定的部分不起作用_C#_Wpf_Data Binding - Fatal编程技术网

C# 数据绑定不';我似乎对某个特定的部分不起作用

C# 数据绑定不';我似乎对某个特定的部分不起作用,c#,wpf,data-binding,C#,Wpf,Data Binding,我正试图为一个学校项目制作一个网络商店。 问题是,在接近底部的地方,我想将所选名称放入文本框,但它似乎不起作用 <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Default="clr-namespace" x:Class="Project.BrowseStor

我正试图为一个学校项目制作一个网络商店。 问题是,在接近底部的地方,我想将所选名称放入文本框,但它似乎不起作用

     <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Default="clr-namespace" x:Class="Project.BrowseStore"
    Title="Browse the store" Height="501.786" Width="735.714" WindowStartupLocation="CenterScreen">
<Grid>
    <Label Content="" HorizontalAlignment="Left" Margin="107.94,65.044,0,0" VerticalAlignment="Top"/>
    <ComboBox x:Name="CmbSort" HorizontalAlignment="Left" Margin="270.627,65.044,0,0" VerticalAlignment="Top" Width="120" IsReadOnly="True" ToolTip="Sorteren" Tag="Sorteren" Text="Sorteren">
        <ComboBoxItem Content="Alle" Selected="ComboBoxItem_Selected_Alle"/>
        <ComboBoxItem Content="Prijs groter dan" Selected="ComboBoxItem_Selected_Prijs"/>
        <ComboBoxItem Content="Prijs kleiner dan" Selected="ComboBoxItem_Selected_Prijs"/>
        <ComboBoxItem Content="Naam" Selected="ComboBoxItem_Selected_Naam"/>
        <ComboBoxItem Content="Boeken" Selected="ComboBoxItem_Selected_Alle"/>
        <ComboBoxItem Content="Games" Selected="ComboBoxItem_Selected_Alle"/>
        <ComboBoxItem Content="Jaaruitgave" Selected="ComboBoxItem_Selected_Jaaruitgave"/>
    </ComboBox>
    <Label Content="Zoeken op" HorizontalAlignment="Left" Margin="122.94,65.044,0,0" VerticalAlignment="Top" Width="82.77" Height="25.96"/>
    <TextBox x:Name="TxtSort" IsEnabled="False" HorizontalAlignment="Left" Height="23" Margin="427.344,65.044,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" RenderTransformOrigin="-0.062,0.519"/>
    <Button x:Name="BtnGo" Content="Go" HorizontalAlignment="Left" Margin="581.075,67.044,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
    <TextBox x:Name="txtTest" HorizontalAlignment="Left" Height="23" Margin="143.761,117.284,0,0" TextWrapping="Wrap" Text="&#xA;" VerticalAlignment="Top" Width="120"/>
    <Button Content="Order" HorizontalAlignment="Left" Margin="130.71,442.226,0,0" VerticalAlignment="Top" Width="75"/>
    <DockPanel x:Name="Panel" Height="282.226" LastChildFill="False" Margin="23.493,155,0,0" VerticalAlignment="Top" Width="683.881">
        <ListView x:Name="lstSort" HorizontalAlignment="Left" Height="138.209" VerticalAlignment="Top" Width="683.881" DockPanel.Dock="Top" IsSynchronizedWithCurrentItem="True">
            <ListView.View>
                <GridView AllowsColumnReorder="False">
                    <GridViewColumn Header="Type" DisplayMemberBinding="{Binding Type}"/>
                    <GridViewColumn Header="Naam"  DisplayMemberBinding="{Binding Naam}"/>
                    <GridViewColumn Header="Prijs" DisplayMemberBinding="{Binding Prijs}"/>
                    <GridViewColumn Header="Jaaruitgave" DisplayMemberBinding="{Binding Jaaruitgave}"/>
                    <GridViewColumn Header="Afbeelding" DisplayMemberBinding="{Binding Afbeelding}"/>
                    <GridViewColumn Header="Uitgever" DisplayMemberBinding="{Binding Uitgever}"/>
                    <GridViewColumn Header="Stock" DisplayMemberBinding="{Binding Stock}"/>



                </GridView>

            </ListView.View>

        </ListView>
        <TextBox Height="144.017" TextWrapping="Wrap" Text="{Binding Naam}" VerticalAlignment="Top" Width="120"/>
    </DockPanel>

</Grid>

这部分似乎不起作用

     <TextBox Height="144.017" TextWrapping="Wrap" Text="{Binding Naam}" VerticalAlignment="Top" Width="120"/>

任何帮助都将不胜感激。

这是使用的示例。看一看。一旦你了解了它是如何工作的,你就会问自己,没有它你是怎么做的:D

这就是修改窗口(XAML)类的方式

现在只需将ViewModel.SelectedItem设置为当前选中的项目(在选择更改时),文本框就会自动更新。我不知道如何将所选行直接绑定到ViewModel.SelectedItem,但它应该是这样的:

<GridView AllowsColumnReorder="False" SelectedValue="{Binding SelectedItem}"> ...
。。。
这是使用的示例。看一看。一旦你了解了它是如何工作的,你就会问自己,没有它你是怎么做的:D

这就是修改窗口(XAML)类的方式

现在只需将ViewModel.SelectedItem设置为当前选中的项目(在选择更改时),文本框就会自动更新。我不知道如何将所选行直接绑定到ViewModel.SelectedItem,但它应该是这样的:

<GridView AllowsColumnReorder="False" SelectedValue="{Binding SelectedItem}"> ...
。。。

这是因为没有为该文本框元素设置DataContext。GridView之所以有效,是因为您(在代码中)将DataContext/Source设置为一些值列表。您可以从GridView绑定当前选定的项,然后将该值绑定到文本框。注释如果你需要代码示例…一个示例会很好。对数据绑定来说还是新鲜事。。。对于meThat来说,它仍然非常混乱,因为您的DataContext没有为TextBox元素设置。GridView之所以有效,是因为您(在代码中)将DataContext/Source设置为一些值列表。您可以从GridView绑定当前选定的项,然后将该值绑定到文本框。注释如果你需要代码示例…一个示例会很好。对数据绑定来说还是新鲜事。。。梅蒂夫仍然很困惑!这帮了大忙:)Tyvm!这帮了大忙:)
<GridView AllowsColumnReorder="False" SelectedValue="{Binding SelectedItem}"> ...