In my WPF application a document has two properties , report name and file name. In the UI the user fills in the report name and the file name is automatically populated with report name as default.
In the dialog that creates new documents i have
<TextBox x:Name="tbReportName" Grid.Row="0" Grid.Column="1" Style="{StaticResource DialogInputStyle}"
Text="{Binding UpdateSourceTrigger=PropertyChanged, Path=ReportName,
ValidatesOnDataErrors=true, NotifyOnValidationError=true}" />
and
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding Text,ElementName=tbReportName,UpdateSourceTrigger=PropertyChanged,Mode=OneWay,Converter={StaticResource safefilenamConverter}}" Style="{StaticResource DialogInputStyle}" >
The report name is bound to a property in the viewmodel and i need to do the same with file name
The user can choose to use the default file name or change it in the textbox. I need to bind the value of the file name textbox to a property in my viewmodel but the binding is already used to get the value from the report name textbox.
Not sure what to use if i want to stay MVVM
Multibinging, triggers…. any ideas?
Does it have to be in XAML? You could just set the FileName property if it’s blank when you set ReportName: