Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6014415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:41:20+00:00 2026-05-23T02:41:20+00:00

I’m trying to get bind a textbox text property to an observable collection, and

  • 0

I’m trying to get bind a textbox text property to an observable collection, and report changes back to the collection. The ContactLog property gets set from the calling page.
This is what I have, but it doesn’t work.

Imports System.ComponentModel
Imports System.Collections.ObjectModel

Public Class cCustomerContactLogFull
    Property ContactLog As ocContactLogs

End Class

Public Class ocContactLogs
    Implements INotifyPropertyChanged

    Private _ContactLogID As Integer
    Private _CustomerID As Integer
    Private _ContactMsg As String

    Private _Changed As Boolean

    Private _ContactLogIDChanged As Boolean
    Private _CustomerIDChanged As Boolean
    Private _ContactMsgChanged As Boolean

    Public Sub New(ByVal contactlogid As Integer, ByVal customerid As Integer, ByVal contactmsg As String)

        _ContactLogID = contactlogid
        _CustomerID = customerid
        _ContactMsg = contactmsg

        _Changed = False

        _ContactLogIDChanged = False
        _CustomerIDChanged = False
        _ContactMsgChanged = False
    End sub

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged

    Protected Overridable Sub OnPropertyChanged(ByVal Propertyname As String)
        If Not Propertyname.Contains("Changed") Then
            Changed = True
        End If
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(Propertyname))
    End Sub

    Public Property Changed() As Boolean
        Get
            Return _Changed
        End Get
        Set(ByVal value As Boolean)
            If _Changed <> value Then
                _Changed = value
                OnPropertyChanged("Changed")
            End If
        End Set
    End Property

    Public Property ContactLogID() As Integer
        Get
            Return _ContactLogID
        End Get
        Set(ByVal value As Integer)
            If _ContactLogID <> value Then
                _ContactLogID = value
                OnPropertyChanged("ContactLogID")
            End If
        End Set
    End Property

    Public Property CustomerID() As Integer
        Get
            Return _CustomerID
        End Get
        Set(ByVal value As Integer)
            If _CustomerID <> value Then
                _CustomerID = value
                OnPropertyChanged("CustomerID")
            End If
        End Set
    End Property

    Public Property ContactMsg() As String
        Get
            Return _ContactMsg
        End Get
        Set(ByVal value As String)
            If _ContactMsg <> value Then
                _ContactMsg = value
                OnPropertyChanged("ContactMsg")
            End If
        End Set
    End Property
End Class

XAML:

<UserControl x:Class="cCustomerContactLogFull"
             x:Name="cCustomerContactLogFull"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             DataContext="ContactLog"
             d:DesignHeight="385" d:DesignWidth="657" Height="482" Width="657">
    <Grid>
        <ScrollViewer Grid.Column="1" Grid.Row="2" Name="ScrollViewer1" Margin="2" VerticalScrollBarVisibility="Auto">
            <TextBox Text="{Binding ContactMsg}" SpellCheck.IsEnabled="True" AcceptsReturn="True" Name="txtContactMsg" TextWrapping="WrapWithOverflow" />
        </ScrollViewer>
    </Grid>
</UserControl>

Whats the right way to bind this?

UPDATE
This is what I’m hoping to do, except without the listview/itemscontrol

<UserControl.Resources>
    <DataTemplate x:Key="centralTile">
        <Grid Background="WhiteSmoke" Width="290" Margin="0,0,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="400*" />
                <ColumnDefinition Width="40" />
            </Grid.ColumnDefinitions>
            <StackPanel Margin="0" HorizontalAlignment="Left" Grid.Column="0" >
                <TextBlock Text="{Binding ContactShort}" Margin="0,0,5,0" FontWeight="Bold" HorizontalAlignment="Left" />
                <TextBlock Text="{Binding Header}" Margin="0,3,5,0" FontWeight="Bold" HorizontalAlignment="Left" />
                <TextBlock Text="{Binding ShortMsg}" Margin="10,3,5,0" FontWeight="Bold" HorizontalAlignment="Left" />
            </StackPanel>
        </Grid>
    </DataTemplate>
    <l:PlainView x:Key="tileView" ItemTemplate="{StaticResource centralTile}" ItemWidth="300" />
</UserControl.Resources>

    <ListView ItemsSource="{Binding ElementName=cCustomerContactInfo, Path=contactlogs}" View="{StaticResource tileView}" Name="lstContactLogs" Margin="0,0,5,28" Grid.Row="1" Grid.Column="2" />

Solution

Ok, learning how to properly use DataContext, this appears to work, and it’s two way, so bonus.

XAML:

<UserControl x:Class="cCustomerContactLogFull"
             x:Name="cCustomerContactLogFull"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="385" d:DesignWidth="657" Height="482" Width="657">
    <UserControl.Resources>
        <DataTemplate x:Key="textBoxTemplate">
            <TextBox Text="{Binding Path=Value}" Width="100"></TextBox>
        </DataTemplate>

        <DataTemplate x:Key="checkBoxTemplate">
            <CheckBox IsChecked="{Binding Path=Value}" IsThreeState="False"></CheckBox>
        </DataTemplate>

    </UserControl.Resources>
    <Grid x:Name="icl">
        <ScrollViewer Grid.Column="1" Grid.Row="2" Name="ScrollViewer1" Margin="2" VerticalScrollBarVisibility="Auto">
            <TextBox Text="{Binding Path=ContactMsg}" SpellCheck.IsEnabled="True" AcceptsReturn="True" Name="txtContactMsg" TextWrapping="WrapWithOverflow" />
        </ScrollViewer>
    </Grid>
</UserControl>

Code Behind:

Imports System.ComponentModel
Imports System.Collections.ObjectModel

Public Class cCustomerContactLogFull
    Property CustomerID As Integer
    Property ContactLog As ocContactLogs

    Private Sub cCustomerContactLogFull_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        If Not ContactLog Is Nothing Then
            icl.DataContext = ContactLog
        End If
    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:41:21+00:00Added an answer on May 23, 2026 at 2:41 am

    You have set your DataContext to the string "ContactLog". This is probably not what you want – you should create and set your DataContext in code, probably in the constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.