2010-04-07 8 views
2

J'ai un datagrid avec certains TextColumn et un DataGridCheckBoxColumn. Je lie avec un itemsource qui contient un booléen et je peux voir que mon checkboxes ou vérifié ou pas par le booléen tout est OK à ce stade.Comment modifier booléen dans un DataGridCheckBoxColumn dans Silverlight 3

Mais les cases à cocher sont en lecture seule même si j'affecte IsReadOnly = False. Je ne peux pas trouver le bon moyen et propre à activer l'édition.

Je n'ai pas besoin de validation de données, mais juste pour pouvoir éditer et cocher ces cases.

enter image description here

+0

Les éléments du ItemsSource ont une propriété inscriptible 'Available'? Un petit échantillon du code xaml et du code aiderait. – AnthonyWJones

Répondre

2

est le mode de liaison mis à TwoWay sur le DataGridCheckBoxColumn?

Ce code fonctionne pour moi.

<data:DataGrid Grid.Row="1" Width="600" MaxHeight="200" 
    GridLinesVisibility="Horizontal" 
    AutoGenerateColumns="False" VerticalScrollBarVisibility="Auto" 
    HorizontalScrollBarVisibility="Auto" 
    ItemsSource="{Binding Path=ProductPull.Items, Mode=OneWay}"> 
     <data:DataGrid.Columns> 
      <data:DataGridCheckBoxColumn Header="Select" 
       Binding="{Binding Path=IsSelected, Mode=TwoWay}" /> 

EDIT

De Silverlight Data Binding ici sont les modes de liaison:

Direction of the Data Flow 
    -------------------------------------------------------------------------------- 

    Each binding has a Mode property, which determines 
how and when the data flows. Silverlight enables three types of bindings: 

    OneTime bindings update the target with the 
source data when the binding is created. 

    OneWay bindings update the target with the 
source data when the binding is created and anytime the data changes. 
This is the default mode. 

    TwoWay bindings update both the target and the 
source when either changes. Alternately, you can disable 
automatic source updates and update the source only at times of your choosing. 

    In order for automatic target updates to occur, 
the source object must implement the INotifyPropertyChanged interface, 
as described in the next section. 
+0

Quelle est la différence entre le mode? – Polo

+1

@Polo - J'ai modifié ma réponse pour inclure les modes de reliure. – DaveB

Questions connexes