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; } .

3
  • When you change the values in your textbox did you check if you ValueConverter is getting the right values that it is expecting? Commented May 18, 2015 at 9: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. Commented May 18, 2015 at 9: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. Commented May 18, 2015 at 9:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.