I have a ListView
that has children with text boxes. These text boxes have validation rules attached to them. It it possible to create some kind of binding that will disable the button when one of the text boxes isn't valid?
Here's a quick example:
<Window x:Class="wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:validationRules="clr-namespace:ValidationRules" Title="MainWindow" Height="350" Width="525">
<DockPanel>
<ListView ItemsSource="{Binding ExampleCollection}">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn Header="Example">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox>
<TextBox.Text>
<Binding Path="Example" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<validationRules:ByteValidationRule/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<Button DockPanel.Dock="Bottom">Save</Button>
</DockPanel>
</Window>