I have a ListBox that loads dynamically using EF. One of the filters used is that the product exists in the stock.
var query = (from p in db.Products
join s in db.Stocks
on new { p.SchoolID, p.ProductID }
equals new { s.SchoolID, s.ProductID }
where
s.Quantity > 0 &&
p.Active == true &&
p.SchoolID == _idSchool &&
p.ProductTypeID == 1
select p);
lst.ItemsSource = query;
XAML code from my ListBox ...
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Border>
<StackPanel Margin="1">
<StackPanel.Background>
<ImageBrush ImageSource="images/btnSalgados.png"/>
</StackPanel.Background>
<TextBlock Margin="0,0,0,0" Padding="4" Width="167" Height="52" TextWrapping="Wrap" Text="{Binding Name}" ToolTip="{Binding Name}"
TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22" Foreground="White" />
<TextBlock Margin="0,0,0,0" Padding="4" Width="167" Height="40" TextWrapping="Wrap" Text="{Binding Price, StringFormat=\{0:N\}}"
TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22" Foreground="White"/>
</StackPanel>
</Border>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
The image of how the ListBox appears to the user ...
I need that if the user selects a product that only has 1 in the stock (because at the selected lolo the stock of the same will be zeroed) this item is disabled for future selections (so that it does not select a product that does not have in stock).