Ich entwickle eine UWP Anwendung. Hier möchte ich wie unten Daten in einer Tabelle Format zeigen,Kann MyToolKit.Extended DataGrid in UWP nicht behandeln
Hier ist mein Ziel I Artikel suchen und diejenigen zu diesem Raster hinzuzufügen. mit out Daten im Raster Wenn ich auf Abgerundete Schaltfläche klicken (rote Farbe ist es eine DataGrid-Header-Vorlage) es funktioniert gut, aber wenn Raster enthält einige Daten in diesem Fall, wenn ich auf abgerundete Schaltfläche klicken unhand-led Exception wie,
Hier bin ich Platzieren Sie den Code, die ich verwendet habe,
<controls:DataGrid x:Name="dgNewBill" Grid.Row="0" Grid.Column="0" MinHeight="500" HorizontalAlignment="Left" HeaderBackground="Black" DefaultOrderIndex="1" Background="Black" RowBackgroundEvenBrush="Black" RowBackgroundOddBrush="Black" >
<controls:DataGrid.RowStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="0"></Setter>
<Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
</Style>
</controls:DataGrid.RowStyle>
<controls:DataGrid.Columns>
<controls:DataGridTextColumn Width="50" Binding="{Binding SNumber}" Foreground="White"
IsAscendingDefault="False" CanSort="False">
<controls:DataGridTextColumn.Header>
<Button x:Uid="RSNO" Height="40" Width="50" HorizontalAlignment="Left" Style="{StaticResource RoundButtonTemplate}" Margin="-10,0,0,0"/>
</controls:DataGridTextColumn.Header>
<controls:DataGridTextColumn.Style>
<Style TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center"></Setter>
</Style>
</controls:DataGridTextColumn.Style>
</controls:DataGridTextColumn>
<!--Item Column-->
<controls:DataGridTextColumn Width="380" Binding="{Binding description}" Foreground="White" CanSort="False">
<controls:DataGridTextColumn.Header>
<Button x:Uid="RItem" Height="40" Width="380" Style="{StaticResource RoundButtonTemplate}" Margin="-12,0,0,0"/>
</controls:DataGridTextColumn.Header>
<controls:DataGridTextColumn.Style>
<Style TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center"></Setter>
</Style>
</controls:DataGridTextColumn.Style>
</controls:DataGridTextColumn>
<!--UOM column-->
<controls:DataGridTextColumn Width="120" Binding="{Binding uom}" Foreground="White" CanSort="False">
<controls:DataGridTextColumn.Header>
<Button x:Uid="RUOM" Height="40" Width="120" Style="{StaticResource RoundButtonTemplate}" Margin="-12,0,0,0"/>
</controls:DataGridTextColumn.Header>
<controls:DataGridTextColumn.Style>
<Style TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center"></Setter>
</Style>
</controls:DataGridTextColumn.Style>
</controls:DataGridTextColumn>
<!--Price Column-->
<controls:DataGridTemplatedColumn>
<controls:DataGridTemplatedColumn.Header>
<Button x:Uid="RPrice" Height="40" Width="110" Style="{StaticResource RoundButtonTemplate}" Margin="-12,0,0,0"/>
</controls:DataGridTemplatedColumn.Header>
<controls:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<StackPanel Name="pricePanel" Width="110" Height="30" Tapped="pricePanel_Tapped" >
<TextBlock Name="price" Foreground="White" Text='{Binding price}' VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,5,0,0"></TextBlock>
</StackPanel>
</DataTemplate>
</controls:DataGridTemplatedColumn.CellTemplate>
</controls:DataGridTemplatedColumn>
<!--Qty Column-->
<controls:DataGridTemplatedColumn>
<controls:DataGridTemplatedColumn.Header>
<Button x:Uid="RQty" Height="40" Width="110" Style="{StaticResource RoundButtonTemplate}" Margin="-25,0,0,0"/>
</controls:DataGridTemplatedColumn.Header>
<controls:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<StackPanel Name="quantityPanel" Width="50" Height="30" Tapped="quantityPanel_Tapped">
<TextBlock Name="quantity" Foreground="White" Text='{Binding quantity}' VerticalAlignment="Center" Margin="0,5,0,0"></TextBlock>
</StackPanel>
</DataTemplate>
</controls:DataGridTemplatedColumn.CellTemplate>
</controls:DataGridTemplatedColumn>
<!--Discount Column-->
<controls:DataGridTemplatedColumn>
<controls:DataGridTemplatedColumn.Header>
<Button x:Uid="Rdiscount" Height="40" Width="60" Style="{StaticResource RoundButtonTemplate}" Margin="-25,0,0,0"/>
</controls:DataGridTemplatedColumn.Header>
<controls:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<StackPanel Name="discountPanel" Width="60" Height="30" Tapped="discountPanel_Tapped" >
<TextBlock Name="Discount" Foreground="White" Text='{Binding discount}' VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,5,0,0"></TextBlock>
</StackPanel>
</DataTemplate>
</controls:DataGridTemplatedColumn.CellTemplate>
</controls:DataGridTemplatedColumn>
<!--Cost Column-->
<controls:DataGridTextColumn Width="110" Binding="{Binding cartTotal}" Foreground="White" CanSort="False" >
<controls:DataGridTextColumn.Header>
<Button x:Uid="RCartTotal" Height="40" Width="110" Style="{StaticResource RoundButtonTemplate}" Margin="-25,0,0,0"/>
</controls:DataGridTextColumn.Header>
<controls:DataGridTextColumn.Style>
<Style TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center"></Setter>
</Style>
</controls:DataGridTextColumn.Style>
</controls:DataGridTextColumn>
<!--void image column-->
<controls:DataGridTemplatedColumn>
<controls:DataGridTemplatedColumn.Header>
<Button Name="Cancelbtn" Height="50" Click="Cancelbtn_Click" Width="55" >
<Image Source="/Images/erase.png" Name="ImgClearCartp" Height="40" Width="40" ></Image>
</Button>
</controls:DataGridTemplatedColumn.Header>
<controls:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<StackPanel Name="voidImagePanel" Width="50" Height="30" Tapped="voidImagePanel_Tapped" >
<Image Name="VoidImage" Source='{Binding imageUrl}' Height="20" Width="30" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,5,0,0"></Image>
</StackPanel>
</DataTemplate>
</controls:DataGridTemplatedColumn.CellTemplate>
</controls:DataGridTemplatedColumn>
</controls:DataGrid.Columns>
</controls:DataGrid>
ich habe getestet und nach meinem Verständnis, wegen mit DataGridTemplatedColumn diese Ausnahme bekommen. Aber nach meinem Umfang muss ich TemplateColumn statt DataGridTextColumn verwenden.
Und ich habe https://github.com/MyToolkit/MyToolkit/wiki/DataGrid
Link verwendet. Bitte schlagen Sie mir vor, wie kann ich dieses Problem lösen?
Vielleicht ist es besser Schreib Problem auf Github wäre? –