PropertyStatus and DatePicker raise System.InvalidOperationException

PropertyStatus and DatePicker raise System.InvalidOperationException

Old forum URL: forums.lhotka.net/forums/t/10962.aspx


simon posted on Wednesday, December 07, 2011

The code as below, run it ,will raise System.InvalidOperationException.

 

 <TabControl Grid.Row="1"  Name="tabControl1"  >

            <TabItem Header="概览" Name="tabItem1">

                <DataGrid x:Name="OverviewDataGrid" 

                       ItemsSource="{Binding Path=Model}" 

                       SelectedItem="{Binding SelectedItem, Mode=TwoWay}" 

 

                       AutoGenerateColumns="False" 

                       IsSynchronizedWithCurrentItem="True" 

                       IsReadOnly="True" CanUserAddRows="True" >

                    <DataGrid.Columns>

                        <DataGridTextColumn Header="BOM编号" Binding="{Binding BOMNo}" Width="100" />

                        <DataGridTextColumn Header="名称" Binding="{Binding Name}"  Width="50"/>

                        <DataGridTextColumn Header="物料编号" Binding="{Binding MaterialNo}"  Width="150"/>

 

                    </DataGrid.Columns>

                </DataGrid>

            </TabItem>

            <TabItem Header="基本" >

                <Grid DataContext="{Binding Path=SelectedItem}">

                    <Grid.RowDefinitions >

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>

                        <ColumnDefinition Width="Auto"/>

                        <ColumnDefinition Width="306"/>

                        <ColumnDefinition Width="25"/>

                        <ColumnDefinition Width="Auto"/>

                        <ColumnDefinition Width="306"/>

                        <ColumnDefinition Width="25"/>

                        <ColumnDefinition Width="*"/>

                    </Grid.ColumnDefinitions>

 

 

                    <DatePicker Grid.Row="4" Grid.Column="1" Width="300" Margin="3" SelectedDate="{Binding Path=ValidFrom,Mode=TwoWay,ValidatesOnExceptions=true, NotifyOnValidationError=true}"/>

                    <csla:PropertyStatus  Grid.Column="2" Grid.Row="4"  Margin="3" Width="20" Height="20" Property="{Binding Path=VaildFrom }"/>           

                </Grid>

            </TabItem>

        </TabControl>

 

 the code have several propertystatus,  if only remove the propertystatus(Bold), it work well

Enviroment: Csla 4.2.1,vs2010

bumnioyo replied on Wednesday, December 07, 2011

I am experiencing the exact same thing!

ve it!

3d
50kPlus Jobs
AcaiBerries
Accounting
Achieve Your Goals
Acne
ActivitiesFor Seniors
AddictionRecovery
AddingA Fish Pond To Your Backyard
AdoptingA Dog
Adoption
AdrenalFatigue
Adsense

Advertising
Aerobics
AffiliateMarketing
AfterSchool Activities
Agriculture
AirlineTickets
AkashicRecords
Allergies
Anti-RecessionTactics
ArcadeGames
Architecture
ArtAuctions
ArtCollecting

ArticleMarketing
AspenNightlife
Asthma
Astrology
AttorneyServices
AutoInsurance Savings
Autoresponders
Aviation
Baby
BackyardActivities
Bankruptcy
Basketball
BedWetting

BehaviorProblems
BestAirfare Deals
Biking
BipolarDisorder
Birthdays
Blogging
BoatInsurance
Boating
BookKeeping
BookMarketing
BrainTraining
Bread Making
BreastAugmentation
Bronchitis

Build AShed
BusinessConsulting
BusinessOutsourcing
Businessto Business
BuyingAnd Selling Websites
BuyingPaintings
CaliforniaHotels
CallCenters
CampingCars
CanineAdult Stem Cells
CarDonation
CarRental

CarRepairs
CarStereo
CardioExercise Equipment
CaringFor Native Wildlife
CaringFor The Elderly
Cats
CeliacDisease
CellPhones
CheeseCake
ChildCare
ChildCustody
Children'sPets
ChineseRecipes

ChocolateLovers
Chocolate-RelatedRecipes
Cigars
CncWoodworking
Coffee
CoinCollecting
Colocation
ContactLenses
ContactingCelebrities
ContentManagement
Cooking
CopywritingServices
CoveredBridges

CreditCards
CreditRepair
CreditScores
CrimeScene Investigation
CriminalDefense Lawyer
CRM
Cruises
CustomerService
Dancing
DangersOf Chlorine
Dating
Deafand Deafness Problem

Decorating and Interior Design
DeepSea Diving
DeepSea Fishing
DepressionAnd Anxiety
Detailing
Diabetes
DiamondJewelry
DieselFuel Prices
Dieting
DigitalPhotography
DiscusFish
Disney

DomainNames Marketing
DownSyndrome
Drywall
DualDiagnosis
Ebay
EbooksFor Children E-commerceShopping Carts
Eczema
EditorialServices
Education
EndOf The World
Exerciseand Training
FamilyReunions

FamilyTree
Feng Shui
FinanceAnd Budget
Fireworks
FishPonds
Fishing
Fitness
Forex
FrenchBulldogs
FuelPrices
Gambling
Gardening
GenericDrugs
GilbertsDisease

GlobalWarming
Glyconutrients
Goat Care
GoldenRetriever
Golf
Gourmet
GreenEnergy Source
HairLoss
Handcrafters
Happiness
Headphones
Healthand Beauty
HealthInsurance
Heartburn

Hemorrhoids
Highway1 Guide
HistoryOf Chess
Historyof Chocolate
Hobbies
Holidays
HomeBuilding Decline
HomeBusiness Model
HomeOffice
HomeRepairs
HomeSecurity
HomeTheater
Homeopathy

How To DJ
IdentityTheft
Immigration
IndoorKids Games
Investing
Ipad
Ivory
JewelryWholesale
JiuJitsu
JobSearch
JointVenture
KeepingChickens
KeepingDucks
Kickboxing

KidneyStones
Landscaping
LaptopComputer Parts
LawOf Attraction
LawnMowers
LeadershipDevelopment
Leads
LearnBaseball
LearnHindi
LearnSpanish
LearnStandup Comedy
LegalForms
LifeCoaching

LiftChairs
Lilies
Livestock
LivingWill
LocalHome Repairman
Lymphoma
Marketing
MarriageHelp
Massage
MedicalTourism
MentalHealth
MetalDetecting
Microwaves
MixedMartial Arts

MobileComputing
Mortgages
Motivation
Motorcycles
Motorhomes
MovieDownload
Muay Thai
MultipleSclerosis
MusicalInstruments
NaturalHealth
Networking
NewForms of Income
New York

NewportBeach
NicheMarketing
NursingCareers
OfficeFurniture
OfflineMarketing
OnlineCollege Degrees
OnlineConsulting
OnlineGames
Optinlist
OptionsTrading
OrganizationTips
Outdoors
P90x

PainRelief
PaintBall
Parenting
Pastlife Regression
PCSecurity
PetHealth Care
Pilates
PlasmaTvs
PlasticSurgery
PlayDrums
Podcasting
Porcelain

PortraitPhotography
PowerGenerator
PowerOf Attorney
PPC
PreciousMetals
PregnancyDress
Preselling
Presentation
PressureWashers
PrivateLabel Resell Rights
Productivity
Psychology
PublicRelations

Quilting
RacingPigeons
Racquetball
Radio
RealEstate
Recycling
Reiki
Retirement
ReverseMortgages
RolePlaying Games
Roofing
RoseaRhodiola
RSS
Running
San Diego

San Francisco
SatelliteTV
SavingEnergy
Schools
Scientology
ScissorliftEquipment
Scotch
SearchEngine Optimization
Seattle
SelfHypnosis
SelfImprovement
SellingYour House
ServiceDogs Dog Training

SettingUp Your Home Aquarium
ShiatsuMassage
SinusInfections
SixPack Abs
Six Sigma
Skateboard
SkiVacations
Skin Care
SkyDiving
Slot Cars
SmallBusiness
SocialNetworking
SolarPower

Spells
SpinningAnd Weaving
Spiritual
SportsCar
SportsFishing
StockMarket
StressManagement
StudentLoans
Stun Guns
Stuttering
SubmissionWrestling
SummerVacations
Sunglasses
Surfing

SwimmingPools
Tattoo
TaxesAnd Your Online Business
Teaching
Tennis
ThailandVacations
TimeManagement
TimeShare Property
Tinnitus(Ear Ringing)
ToothacheAnd Tooth Care
TrackingSoftware
Trademarks

TradingStocks Online
TrafficSchool
Trains
Travel
TropicalFish
U.S.Bank Accounts
UniversalStudio Tours
VacationIn Greece
Valentine'sDay
VideoSites
VintagePosters
ViralMarketing
VirusAlert

VitaminsAnd Supplements
VoiceOver Internet Protocol
Water Color
WaterSki
Waterproofing
WebConferencing
WebDesign
Web Hosting
WebTraffic
Weddings
WeightLoss
Wi FiSpots
WineAnd Spirits

WineGift Baskets
Winterizing
WomenSelf Defense
Women'sHealth
Woodworking
WorkplaceSafety
Yoga Ebooks | Contact Us | About | Advertisewith Us |Sitemap |Miscellaneous Articles | Extras | Misc1 | Misc2 | Misc3 | Misc4 | Misc5 | Misc6 | Misc7 | Misc8 | Misc9 | Misc10 | Misc11 | Misc12 | Misc13 }| Misc14 | Misc15 | Misc16 | Misc17 | Misc18 | Misc19 | Misc20 | Misc21 | Misc22 | Misc23 | Misc24 | Misc25 | Misc26 | Misc27 | Misc28 | Misc29 | Misc30 | Misc31 | Misc32 | Misc33 | Misc34 | Misc35 | Misc36 | Misc37This is an excellent site I love it

 

simon replied on Wednesday, December 07, 2011

I look up a old post:http://forums.lhotka.net/forums/p/7389/35383.aspx#35383.   I tried to remove the tabcontrol, but it still not work. and i change my code as below, it can work.

 

 <TabItem Header="基本" >

                <Grid >

                    <Grid.RowDefinitions >

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                        <RowDefinition Height="Auto"/>

                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>

                        <ColumnDefinition Width="Auto"/>

                        <ColumnDefinition Width="306"/>

                        <ColumnDefinition Width="25"/>

                        <ColumnDefinition Width="Auto"/>

                        <ColumnDefinition Width="306"/>

                        <ColumnDefinition Width="25"/>

                        <ColumnDefinition Width="*"/>

                    </Grid.ColumnDefinitions>

 

                    <Label  Content="物料清单编号:" Grid.Row="0" Grid.Column=" 0"/>

                    <TextBox Grid.Row="0" Grid.Column="1" Width="300" Text="{Binding SelectedItem.BOMNo,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DefaultTextBoxStyle}"/>

 

                    <Label Content="物料清单名称:" Grid.Row="1" Grid.Column="0"/>

                    <TextBox  Grid.Row="1" Grid.Column="1" Width="300" Text="{Binding SelectedItem.Name,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DefaultTextBoxStyle}"/>

 

                    <Label Content="描述:" Grid.Row="2" Grid.Column="0"/>

                    <TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="4" Width="483" Height="40" Text="{Binding Path=Descripition, UpdateSourceTrigger=PropertyChanged }"  Style="{StaticResource DefaultTextBoxStyle}" Margin="3,3,0,3" />

 

                    <Label Content="物料:" Grid.Row ="3" Grid.Column="0"/>

                    <StackPanel Grid.Row="3" Grid.Column="1" Width="300" HorizontalAlignment="Left"  Orientation="Horizontal">

                        <TextBox Width="250" Margin="3" Text="{Binding Path=SelectedItem.MaterialNo}" IsReadOnly="True" />

                        <Button Width="30" Margin="3" Content="..." Command="{Binding Path=DataContext.SetMaterialCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}"/>

                    </StackPanel>

                    <Label Grid.Row="3" Grid.Column="3" Content="{Binding MaterialName}"/>

 

                    <Label Content="生效日期:" Grid.Row="4" Grid.Column="0"/>

                    <DatePicker Grid.Row="4" Grid.Column="1" Width="300" Margin="3" SelectedDate="{Binding Path=SelectedItem.ValidFrom,Mode=TwoWay,ValidatesOnExceptions=true, NotifyOnValidationError=true}"/>

 

 

                    <csla:PropertyStatus Grid.Column="2" Grid.Row="0" Margin="3" Width="20" Height="20" Property="{Binding Path=SelectedItem.BOMNo }" />

                    <csla:PropertyStatus Grid.Column="2" Grid.Row="1" Margin="3" Width="20" Height="20" Property="{Binding Path=SelectedItem.Name }" />

                    <csla:PropertyStatus Grid.Column="2" Grid.Row="3" Margin="3" Width="20" Height="20" Property="{Binding Path=SelectedItem.MaterialNo }"/>

                    <csla:PropertyStatus  Grid.Column="2" Grid.Row="4"  Margin="3" Width="20" Height="20" Property="{Binding Path=SelectedItem.VaildFrom}"/>

                </Grid>             

            </TabItem>

 

simon replied on Thursday, December 08, 2011

用户代码未处理 System.NullReferenceException

  Message=未将对象引用设置到对象的实例。

  Source=Csla

  StackTrace:

       在 Csla.Reflection.MethodCaller.GetPropertyValue(Object obj, PropertyInfo info)

       在 Csla.Xaml.PropertyStatus.GetRealSource(Object source, String bindingPath)

       在 Csla.Xaml.PropertyStatus.SetSource(Object dataItem)

       在 Csla.Xaml.PropertyStatus.<.ctor>b__2(Object o, DependencyPropertyChangedEventArgs e)

       在 System.Windows.FrameworkElement.RaiseDependencyPropertyChanged(EventPrivateKey key, DependencyPropertyChangedEventArgs args)

       在 System.Windows.FrameworkElement.OnDataContextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

       在 System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)

       在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)

       在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)

       在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)

       在 System.Windows.TreeWalkHelper.OnInheritablePropertyChanged(DependencyObject d, InheritablePropertyChangeInfo info)

       在 System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d)

       在 System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe)

       在 System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d)

       在 System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren)

       在 System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren)

       在 System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d)

       在 System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d)

       在 System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe)

       在 System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d)

       在 System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren)

       在 System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren)

       在 System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d)

       在 System.Windows.DescendentsWalker`1.StartWalk(DependencyObject startNode, Boolean skipStartNode)

       在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)

       在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)

       在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)

       在 System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)

       在 System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)

       在 System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)

       在 System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)

       在 MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)

       在 MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)

       在 MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)

       在 MS.Internal.Data.PropertyPathWorker.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)

       在 System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)

       在 System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)

       在 Csla.Xaml.ViewModelBase`1.OnPropertyChanged(String propertyName)

       在 MES.Presentation.WPF.Client.MM.Views.BOMViews.BOMsViewModel.set_SelectedItem(BOMItemViewModel value) 位置 E:\MES\MES.Presentation.WPF.Client.MM\Views\BOMViews\BOMsViewModel.cs:行号 53

  InnerException: 

simon replied on Sunday, December 11, 2011

Confused

Copyright (c) Marimer LLC