, ,
<sdk:AutoCompleteBox ItemsSource="{Binding Sites, Source={StaticResource VmSchedulel}}" ValueMemberPath="SiteName"
SelectedItem="{Binding Site, Mode=TwoWay}" FilterMode="ContainsOrdinal">
<sdk:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding SiteName}"/>
</DataTemplate>
</sdk:AutoCompleteBox.ItemTemplate>
</sdk:AutoCompleteBox>
If you enter any text that does not match anything in the ItemsSource element, SelectedItem will be zero. In the set method of your property, you can simply not set the value, because it is null, and the property will retain its original value.
set
{
if (value != null)
{
BaseRecord.SiteID = value.ID;
PropChanged("Site");
}
}
source
share