Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess my Views from bound ItemsControl
    primarykey
    data
    text
    <p>I have a typical MVVM scenario: I have an <code>ItemsControl</code> bound to an <code>ObservableCollection</code> of StepsViewModels. I define a DataTemplate so that StepViewModels are rendered as StepViews. The same happens in the StepView: I have an <code>ItemsControl</code> to an <code>ObservableCollection</code> of ParameterViewModels with a DataTemplate to render them as ParameterViews.</p> <p>My problem is: I have to refresh the <code>ItemsControl</code> to render items added and remove items. I can refresh the <code>ItemsControl</code> with StepViews, because I have access to it and can call ItemsControl.Items.Refresh(). But how can I access the StepViews so I can call a Refresh method? ItemsControl Items are StepViewModels...</p> <p>Here is the code:</p> <pre><code>&lt;UserControl x:Class="mylib.EditorView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:mylib"&gt; &lt;UserControl.Resources&gt; &lt;DataTemplate DataType="{x:Type my:StepViewModel}"&gt; &lt;my:StepView HorizontalAlignment="Stretch"/&gt; &lt;/DataTemplate&gt; &lt;/UserControl.Resources&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="27"/&gt; &lt;RowDefinition Height="*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" VerticalAlignment="Top"&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;TextBlock Name="lblHelpRefresh" Margin="0 7 0 7" Visibility="{Binding HelpVisible}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="9pt" Foreground="#949494" Text="Please click refresh to reload this list"/&gt; &lt;ItemsControl Name="stkStepContent" ItemsSource="{Binding Steps}"/&gt; &lt;/StackPanel&gt; &lt;/ScrollViewer&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p>How can I access the StepView controls that render the stkStepContent Items?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload