Note that there are some explanatory texts on larger screens.

plurals
  1. POset deledate in ItemsControl ResourceDictionary
    primarykey
    data
    text
    <p>First, let me show you how my code is cut.</p> <p>I have this code in a xaml UC (eventsUC.xaml) :</p> <pre><code>&lt;UserControl x:Class="QuimeO.UserControls.Lists.EventsListUC" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ToggleSwitch="clr-namespace:ToggleSwitch;assembly=ToggleSwitch" mc:Ignorable="d" Width="477" &gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="*" /&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;ScrollViewer HorizontalScrollBarVisibility="Disabled" Width="auto" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"&gt; &lt;ItemsControl Grid.Row="0" BorderThickness="0" x:Name="eventsList" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled"&gt; &lt;ItemsControl.Resources&gt; &lt;ResourceDictionary x:Name="eventslisttempplate" Source="EventsListTemplate.xaml" /&gt; &lt;/ItemsControl.Resources&gt; &lt;/ItemsControl&gt; &lt;/ScrollViewer&gt;... </code></pre> <p>My EventsListTemplate.xaml looks like this :</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="QuimeO.UserControls.Lists.EventsListTemplate" xmlns:apiNamespace="clr-namespace:QuimeO.DBO" &gt; &lt;DataTemplate DataType="{x:Type apiNamespace:EventsDictionary}"&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0,0,0,1" Margin="0,5,0,0"&gt; &lt;TextBlock HorizontalAlignment="Right" Foreground="Gray" Text="{Binding FormatedDate}" FontSize="14"&gt;&lt;/TextBlock&gt; &lt;/Border&gt; &lt;ListView Grid.Row="0" x:Name="eventsList" ItemsSource="{Binding Events}" BorderThickness="0" MouseDoubleClick="eventsList_MouseDoubleClick"&gt; &lt;/ListView&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>And my EventsListTemplate.xaml.cs code behind looks like this </p> <pre><code>public partial class EventsListTemplate : ResourceDictionary { public Delegate MainWindowControlPointer; private void eventsList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var ev = ((sender as ListView).SelectedItem as ListViewItem).DataContext as Event; System.Diagnostics.Debug.WriteLine(ev.Name); this.MainWindowControlPointer.DynamicInvoke(ev.Ancestors.Root, new Element() { Category = ev.Category, Id = ev.Id, Name = ev.Name }); } } </code></pre> <p>When I click on an item of my listview in my template, it trigger the eventsList_MouseDoubleCkick and I can retrieve my event.</p> <p>However, I would like to trigger an action in the UC where the template is created (first source code block).</p> <p>To do that, I just want to create a delegate in my Template (technicaly, in a perfect world, something like "this.rd_eventslisttemplate.MainWindowControlPointer = ... "). But, I don't know how to do it or if this is even possible.</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.
    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