1

Silverlight 系统,其中一个 asp 用户药房有一个用于他们的库存的链接表。我正在尝试在列表(数据网格)中显示此库存,并为他们提供一种通过数据网格编辑和添加项目到列表的方法。目前我正在努力绑定这个数据表单......提供了 Xaml,有什么帮助吗?

<Grid x:Name="LayoutRoot">
    <Button Content="Save Changes" Height="52" Width="103" Name="SaveChangesButton" VerticalAlignment="Top" Click="SaveChanges" ContentTemplate="{Binding}" Margin="169,309,367,0" />
    <Button Content="Discard Changes" Height="52" Width="103" Name="DiscardChangesButton" VerticalAlignment="Top" Click="DiscardChanges" ContentTemplate="{Binding}" Margin="288,309,250,0" />
    <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:User_Pharmacy, CreateList=true}" Height="0" LoadedData="user_PharmacyDomainDataSource_LoadedData_1" Name="user_PharmacyDomainDataSource" QueryName="GetUser_PharmacyMedInvASPQuery" Width="0">
        <riaControls:DomainDataSource.DomainContext>
            <my1:MediNetDomainContext />
        </riaControls:DomainDataSource.DomainContext>
    </riaControls:DomainDataSource>
    <sdk:DataGrid AutoGenerateColumns="False" Height="406" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=user_PharmacyDomainDataSource, Path=Data}" Margin="12,37,0,0" Name="medicineInventoryDataGrid" VerticalAlignment="Top" Width="107" >
        <sdk:DataGrid.Columns>
            <sdk:DataGridTextColumn x:Name="medName" Binding="{Binding Path=MedicineName}" Header="Medicine Name" Width="SizeToHeader" Visibility="Visible" />
        </sdk:DataGrid.Columns>
    </sdk:DataGrid>
    <TextBlock Height="23" HorizontalAlignment="Left" Margin="336,420,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" />
    <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:User_Pharmacy, CreateList=true}" Height="0" LoadedData="user_PharmacyDomainDataSource1_LoadedData" Name="user_PharmacyDomainDataSource1" QueryName="GetUser_PharmacyASPQuery" Width="0">
        <riaControls:DomainDataSource.DomainContext>
            <my1:MediNetDomainContext />
        </riaControls:DomainDataSource.DomainContext>
    </riaControls:DomainDataSource>
    <toolkit:DataForm HorizontalAlignment="Left" Margin="151,37,0,0" Name="dataForm1" VerticalAlignment="Top" Width="258" Height="223" ItemsSource="{Binding ElementName=user_PharmacyDomainDataSource, Path=Data.}" CommandButtonsVisibility="All">
        <toolkit:DataForm.ReadOnlyTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <sdk:Label Content="Medicine Name:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="medicineNameTextBox" Text="{Binding Path=MedicineName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="True"/>
                    <sdk:Label Content="Price:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3" Name="priceTextBox" Text="{Binding Path=Price, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="True"/>
                    <sdk:Label Content="Quantity:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="3" Name="quantityTextBox" Text="{Binding Path=Quantity, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="True" />
                </Grid>
            </DataTemplate>
        </toolkit:DataForm.ReadOnlyTemplate>
        <toolkit:DataForm.NewItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <sdk:Label Content="Medicine Name:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="medicineNameTextBox" Text="{Binding Path=MedicineName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="False"/>
                    <sdk:Label Content="Price:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3" Name="priceTextBox" Text="{Binding Path=Price, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="False"/>
                    <sdk:Label Content="Quantity:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="3" Name="quantityTextBox" Text="{Binding Path=Quantity, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="False" />
                </Grid>
            </DataTemplate>
        </toolkit:DataForm.NewItemTemplate>
        <toolkit:DataForm.EditTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <sdk:Label Content="Medicine Name:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="medicineNameTextBox" Text="{Binding Path=MedicineName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="False"/>
                    <sdk:Label Content="Price:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3" Name="priceTextBox" Text="{Binding Path=Price, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="False"/>
                    <sdk:Label Content="Quantity:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                    <TextBox Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="3" Name="quantityTextBox" Text="{Binding Path=Quantity, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" IsReadOnly="False" />
                </Grid>
            </DataTemplate>
        </toolkit:DataForm.EditTemplate>
    </toolkit:DataForm>
</Grid>

4

1 回答 1

0

使用两组文本块创建我自己的自定义版本,一组用于编辑/添加,仅在那时可见,另一组用于查看。如果有人有兴趣,我可以分享代码。

于 2012-10-18T11:53:38.613 回答