Hello,
I've WPF application in which I'm loading user controls dynamically in my MainWindow.xaml using ContentPresenter, on change of a value in the combox present on MainWindow.xaml.
MainWindow.xaml:
<ContentPresenter Content="{Binding CurrentViewModel}" Grid.ColumnSpan="7" Grid.RowSpan="11" Grid.Row="11" > <ContentPresenter.Resources> <DataTemplate DataType="{x:Type ViewModel:AVM}" > <Views:A/> </DataTemplate> <DataTemplate DataType="{x:Type ViewModel:BVM}" > <Views:B/> </DataTemplate> </ContentPresenter.Resources> </ContentPresenter>
Each view(A, B, C etc.) have different number of textboxes.Developers will be adding n number of views in the future.
My requirement is that I need to apply the following style dynamically to textbox if that control's value is blank or empty.(Style will be present in Mainwindow.xaml)
Can this be achieved please?Also, could you advise on what the value for Path in the below style should be?
<Style TargetType="TextBox" x:Key="MandatoryFieldStyle"> <Style.Triggers> <DataTrigger Binding="{Binding Path=??}" Value="true"> <Setter Property="Background" Value="BurlyWood" /> </DataTrigger> <DataTrigger Binding="{Binding Path=??}" Value="false"> <Setter Property="Background" Value="LightGreen" /> </DataTrigger> </Style.Triggers> </Style>
Thanks.