0

When using ItemsControl to bind to a property of type List<byte>, I get the correct values in one direction (displayed using a TextBox with a hexadecimal StringConverter), but changing the value has no effect (i.e. the source is not updated). Binding mode is the default. Changing the property to be a ObservableCollection instead of a list has no effect. (The problem is independent of whether the StringConverter is used or not.)

The item template (working in the source-to-display direction) I'm using below.

            <ItemsControl
                ItemsSource="{Binding Context.ContentBytes}">

                <!-- Container configuration -->
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid Columns="8" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>

                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBox
                            Margin="5,5,5,5"
                            Text="{Binding .}" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>

            </ItemsControl>

The property I'm binding to is defined as public ObservableCollection<byte> ContentBytes { get; set; } .

pmf
  • 7,619
  • 4
  • 47
  • 77
  • When you change the values in your textbox did you check if you ValueConverter is getting the right values that it is expecting? – Krishna May 18 '15 at 09:13
  • 1
    Show us more code: the defintion of whatever `Context` is (if it's large, just show the definition and `ContentBytes` defined within) and tell us how you're updating `ContentBytes`. – Charles Mager May 18 '15 at 09:19
  • 2
    Editing and thus *changing* the elements of a collection does not *replace* them in the collection. However, your changes get lost because the element type is a value type, not a reference type. – Clemens May 18 '15 at 09:59

0 Answers0