This is a migrated thread and some comments may be shown as answers.

Radwindow sometimes open multiple instances

1 Answer 51 Views
Window
This is a migrated thread and some comments may be shown as answers.
peter
Top achievements
Rank 1
peter asked on 18 Sep 2012, 10:50 AM
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?

1 Answer, 1 is accepted

Sort by
0
Attila
Top achievements
Rank 1
answered on 02 Apr 2013, 02:25 PM
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.
Tags
Window
Asked by
peter
Top achievements
Rank 1
Answers by
Attila
Top achievements
Rank 1
Share this question
or