Vote count:
0
I have two grid panels of which each has one RadGridView and three buttons (Add/Delete/Save). Please refer the XAML code given below.
We can perform add/delete/save by clicking on the corresponding buttons which is at the bottom right corner in each panel. So whenever there is a change in RadGridView items source, validation method in my viewmodel should be invoked from there and it will return the list of error messages if any.
When we found any errors then system shouldn't allow user switching between the panels (i.e. not to move focus out of the panel which has list of errors specific to RadGridView) until all the validation errors are cleared out. So the point is it won't allow user to edit RadGridView in one panel if there is an error found in other panel's grid view. Once all my validations are passed, we can switch between those panels and do changes in grid data.
I have used PreviewLostKeyboardFocus event for both panels inside which my validation method has been invoked. But this event got triggered multiple times and somewhere it doesn't allow to fire Add/Save/Delete button click event.
Can we use grid panels or do we have any other layouts/controls to achieve this. Hope I'm clear with my points. Please let me know if you need any more info on this.
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" x:Name="grdPanel1Section">
<Grid.RowDefinitions>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition MinHeight="100"></RowDefinition>
<RowDefinition Height="35"></RowDefinition>
</Grid.RowDefinitions>
<Label Content="Panel 1" ></Label>
<tk:RadGridView Margin="2,2" Grid.Row="1" AutoGenerateColumns="False" ShowColumnHeaders="True" ShowGroupPanel="False" x:Name="grdPanel1" IsReadOnly="True" ItemsSource="{Binding panel2Itemsource}"
ActionOnLostFocus="None">
<tk:RadGridView.Columns>
<tk:GridViewDataColumn Header="Id" DataMemberBinding="{Binding Id, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True">
</tk:GridViewDataColumn>
<tk:GridViewDataColumn Header="Start Date" DataMemberBinding="{Binding StartDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True">
</tk:GridViewDataColumn>
<tk:GridViewDataColumn Width="100" Header="End Date" DataMemberBinding="{Binding EndDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True">
</tk:GridViewDataColumn>
<tk:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" IsReadOnly="True"/>
<tk:GridViewDataColumn Header="Flag" DataMemberBinding="{Binding Flag}" IsReadOnly="True"/>
</tk:RadGridView.Columns>
</tk:RadGridView>
<StackPanel Grid.Row="2" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="5,5">
<tk:RadButton Width="75" Content="Add" x:Name="btnAddPanel1" />
<tk:RadButton Width="75" Content="Save" x:Name="btnSavePanel1"/>
<tk:RadButton Width="75" Content="Delete" x:Name="btnDeletePanel1"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1" x:Name="grdPanel2Section">
<Grid.RowDefinitions>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition MinHeight="100"></RowDefinition>
<RowDefinition Height="35"></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Panel 2" ></Label>
<tk:RadGridView Margin="2,2" Grid.Row="1" AutoGenerateColumns="False" ShowColumnHeaders="True" x:Name="grdPanel2" IsReadOnly="True" ItemsSource="{Binding panel2Itemsource}" ActionOnLostFocus="None" TabIndex="29">
<tk:RadGridView.Columns>
<tk:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True">
</tk:GridViewDataColumn>
<tk:GridViewDataColumn Width="100" Header="Description" DataMemberBinding="{Binding Desc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True">
</tk:GridViewDataColumn>
<tk:GridViewDataColumn Width="100" Header="Date" DataMemberBinding="{Binding Date, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True">
</tk:GridViewDataColumn>
<tk:GridViewDataColumn Width="100" Header="Status" DataMemberBinding="{Binding Status}" IsReadOnly="True"/>
<tk:GridViewDataColumn Width="200" Header="Points" DataMemberBinding="{Binding Points}" IsReadOnly="True"/>
</tk:RadGridView.Columns>
</tk:RadGridView>
<StackPanel Grid.Row="2" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="5,5">
<tk:RadButton Width="75" Content="Add" x:Name="btnAddPanel2" />
<tk:RadButton Width="75" Content="Save" x:Name="btnSavePanel2" />
<tk:RadButton Width="75" Content="Delete" x:Name="btnDeletePanel2"/>
</StackPanel>
</Grid>
</Grid>
Block-level HTML elements have a few restrictions: 1.They must be separated from surrounding text by blank lines. 2.The begin and end tags of the outermost block element must not be indented. 3.Markdown can't be used within HTML blocks.
Thanks
asked 1 min ago
Prevent switching between grid layout panels in wpf
Aucun commentaire:
Enregistrer un commentaire