I have a list of objects of type "BasicVariable", a% of them%, and I need the Graphic Interface to show a Label when the number of items in this collection exceeds 1000, I think the binding is correct but I did not get one how the counter and UI are updated every addition / removal of an object of this class ...
Here is the label I need to update:
<Label x:Name="configFilePath_Copy" Content="BasicVariable can't exceed 1000" HorizontalAlignment="Right" Margin="0,0,11,62" VerticalAlignment="Bottom" RenderTransformOrigin="0.5,0.5" Width="154" Foreground="Red">
<Label.Style>
<Style TargetType="{x:Type Label}">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding BVExceed}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
Here I collapsed a Boolean property that returns whether or not it has more than 1000 objects
public bool BVExceed
{
get { return NumberOfBasicVariablesExceeded(); }
set
{
if(value != NumberOfBasicVariablesExceeded())
{
NumberOfBasicVariablesExceeded();
RaisePropertyChanged("BVExceeded");
}
}
}
Here the method that interacts with the other viewmodel that has ObservableCollection
public bool NumberOfBasicVariablesExceeded()
{
if (BasicVariableViewModel != null)
{ return (BasicVariableViewModel.BasicVariables.Count >= 1000); }
else
return false;
}
As I'm new to the MVVM and WPF standard, I know that my implementation is wrong in both code and XAML, I would like to understand exactly how to do this binding of datatriggers in order to implement correctly