Thursday, 22 August 2013

Having a button enabled in WPF based on dataview values

Having a button enabled in WPF based on dataview values

I have a dataview thats binded to a Class called Activity. In the grid
there are two columns which are a checkbox column and textbox
respectively.
I would like to add code that enables a button if at least one of the
checkboxes are checked and one of the textboxes has a certain string. I
thought about creating a new Property in the Activity class and binding
that to an "isEnabled" property but am not sure that would work since
theres no set method that would fire the NotifyPropertyChanged.
Any suggestions?
<DataGrid Name="dataGrid" HorizontalAlignment="Center"
CanUserAddRows="False" CanUserReorderColumns="False"
HeadersVisibility="Column" Margin="0,28,0,0" VerticalAlignment="Top"
Height="262" AutoGenerateColumns="False" ItemsSource="{Binding
Activities}" SelectedItem="{Binding SelectedActivity, Mode=TwoWay}">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Enabled">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center"
VerticalAlignment="Center" IsChecked="{Binding
Enabled, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

No comments:

Post a Comment