Radwindow sometimes open multiple instances

2 posts, 0 answers
  1. peter
    peter avatar
    37 posts
    Member since:
    Feb 2011

    Posted 18 Sep 2012 Link to this post

    Hi i have a radwindow, the problem is sometimes it opens up multiple instances of the window, this is a problem because only one instance of it should be opened.
    <Telerik:RadWindow 
        x:Class="CLA.StaticDataProcessing.Views.Dashboard.EventHistory"
        xmlns:clr="clr-namespace:System;assembly=mscorlib"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
        mc:Ignorable="d"
        xmlns:vm="clr-namespace:CLA.StaticDataProcessing.ViewModels"
        xmlns:ClassLibrary="clr-namespace:CLA.SL.Apps.ClassLibrary;assembly=CLA.SL.Apps.ClassLibrary"
        Height="600"
        Width="1000"
        ModalBackground="Transparent"                 
        CanClose="True"
        Header="Event History"
        WindowStartupLocation="CenterOwner">
         
        <Telerik:RadWindow.Resources>
            <vm:EventDetailHistoryDTOViewModel x:Key="vm"></vm:EventDetailHistoryDTOViewModel>
        </Telerik:RadWindow.Resources>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Closed">
                <cmd:EventToCommand Command="{Binding ClickCommand, Source={StaticResource vm}}" CommandParameter="closewindow"></cmd:EventToCommand>
            </i:EventTrigger>
                <i:EventTrigger EventName="Loaded">
                <cmd:EventToCommand Command="{Binding LoadCommand, Source={StaticResource vm}}" CommandParameter="{Binding ID}"></cmd:EventToCommand>
                </i:EventTrigger>
        </i:Interaction.Triggers>
        <Grid x:Name="LayoutRoot" Background="White"  DataContext="{Binding}">
            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" Margin="0,0,0,142">
                <TextBlock FontFamily="Segoe UI Light" FontSize="30" Foreground="{StaticResource AccentBrush}"  Text="{Binding EntityName}"></TextBlock>
                <TextBlock Text=" - " Foreground="{StaticResource AccentBrush}" FontSize="30"  ></TextBlock>
                <TextBlock FontFamily="Segoe UI Light" Foreground="{StaticResource AccentBrush}" FontSize="30"   Text="{Binding FormName}"></TextBlock>
            </StackPanel>
            <Telerik:RadGridView AutoGenerateColumns="False"  RowHeight="50" ItemsSource="{Binding PagedSource, ElementName=_radDataPager}" CanUserFreezeColumns="False" ShowGroupPanel="False" Margin="0,43,0,54" Grid.RowSpan="3">
                <Telerik:RadGridView.Columns>
                    <Telerik:GridViewDataColumn Header="Internal Comment" IsReadOnly="True" TextWrapping="Wrap"  DataMemberBinding="{Binding InternalComment,TargetNullValue='-'}" Width="2*"/>
                    <Telerik:GridViewDataColumn Header="External Comment" TextWrapping="Wrap"  DataMemberBinding="{Binding ExternalComment,TargetNullValue='-'}" Width="2*"/>
                    <Telerik:GridViewDataColumn Header="Current State" IsReadOnly="True" DataMemberBinding="{Binding CurrentState}" Width="1*"/>
                    <Telerik:GridViewDataColumn Header="Next State" IsReadOnly="True" DataMemberBinding="{Binding NextState}" Width="1*"/>
                    <Telerik:GridViewDataColumn Header="ChangedBy" IsReadOnly="True" DataMemberBinding="{Binding ChangedBy}" Width="1*"/>
                    <Telerik:GridViewDataColumn Header="ChangedOn" IsReadOnly="True" DataMemberBinding="{Binding ChangedOn}" Width="1*"/>
                </Telerik:RadGridView.Columns>
            </Telerik:RadGridView>
            <Telerik:RadDataPager      Grid.Row="2"
                                       x:Name="_radDataPager"
                                       PageSize="10"
                                       Margin="0,158,0,0"
                                       DisplayMode="All"
                                       IsTotalItemCountFixed="True"
                                       VerticalAlignment="Bottom"
                                       Source="{Binding BindsDirectlyToSource=True, Path=EventDetailHistoryDTOs, Source={StaticResource vm}, TargetNullValue=''}" />
      
        </Grid>
    </Telerik:RadWindow>

    I open it this way;

     

     

     

     

    EventHistory eventHistory = new EventHistory();
      
    eventHistory.DataContext = staticDataRadGrid.SelectedItem;
      
    eventHistory.ShowDialog();

    Can anyoen see what I am doing wrong?

  2. Attila
    Attila avatar
    1 posts
    Member since:
    Mar 2013

    Posted 02 Apr 2013 Link to this post

    Typically this can happen when the event handler that opens the window is invoked multiple times. The event subscription code might be invoked more than once, or there are several object instances that are listening to the same event. It's also possible, that an object, that is supposed to be disposed still exists (e.g. there is a reference that points at it) and that also handles the event.
  3. DevCraft banner
Back to Top