Reputation: 883
I have a user control which is driven by data from a sql database. Each user control contains a query, which can be altered at runtime with parameters. I would like to replicate the functionality of the reporting services viewer, which has the prompt area as seen in the image below.
The example shown is made up of a single label and textbox. I am currently working towards an implementation like this. However it would be beneficial to be able to provide the users with a list of valid values, to ensure valid data is returned. It would also be nice to have dependencies between controls.
Does anyone know of an examples/implementations of something similar to this? Or any resources which could help with a solution?
Upvotes: 0
Views: 127
Reputation: 883
Just for reference for others. I managed to implement this functionality using a list of a custom class along with a items collection.
Shown below is the Xaml. You can see the ItemsSource is bound to a list of my parameter class, and the item template binds a label/textbox to properties for each parameter.
<Grid Background="Silver">
<ItemsControl Grid.IsSharedSizeScope="True" ItemsSource="{Binding Path=Parameters}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="Labels" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Path=Prompt}" Grid.Column="0" TextAlignment="Right"/>
<TextBox Text="{Binding Path=Value}" Width="200" Grid.Column="1"/>
</Grid>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
This is the output, for now it is as simple as labels and textboxes. I will come back to this and improve to use combos with limited values.
Upvotes: 0