Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Codeproject comunity. I came to ask ur help becouse i still cant figure it out what is happening. Im working with WPF XAML Net Framework 4.8

i have a listview that get information of an API so when i select one of the items its should redirect on the same parent frame to another page and show the PDF in a webbrowser that mactch with that register.. Well that is working fine .. but after i redirect and go back the controls of filter datepicker didnt work, even the parent frame when i go to another frame and try to execute another module its go call the api but no redirect to childs pages .. So i changed to look the pdf in the same page but in another grid and ok still keep the same problem ..

Remember all is in the same Parent frame so i have an menu and redirect on the same frame all modules

idk if the problem is that im calling this redirect navigation inside a selection_Changed of the listview even happen the same in datagrid SelectedCellsChanged

I hope u can help me thanks !

this is my code

AutorizadosPage.xaml
<Page x:Class="Olimpia.AppWindows.Cliente.View.autorizadosPage"
      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:ui="http://schemas.modernwpf.com/2019"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="autorizadosPage">

    <Border CornerRadius="5" Background="{DynamicResource SecundaryBackgroundColor}">
        <Grid>
            <Grid x:Name="TramitesGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="60"/>
                <RowDefinition Height="35"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="35"/>
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Text="Trámites Autorizados" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="15,0,0,0" Style="{StaticResource TituloTextBlock}"/>

            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="70*"/>
                    <ColumnDefinition Width="30*" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0"  Orientation="Horizontal">
                    <Button   x:Name="RefrescarButton" Style="{StaticResource CancelarTramiteButtonsStyle}" VerticalAlignment="Center" Width="100"  HorizontalAlignment="Left" Margin="10,0,10,0" Click="RefrescarButton_Click" >
                        <StackPanel Orientation="Horizontal">
                            <Path x:Name="reloadIcon" Grid.Column="0" Width="15" Height="13" Stretch="Fill" Fill="{StaticResource PrimaryColor }" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,7,0"  Data="{DynamicResource reload}"/>
                            <TextBlock Text="Refrescar" VerticalAlignment="Center"/>
                        </StackPanel>
                    </Button>
                    <Path x:Name="handIcon" Grid.Column="0" Width="13" Height="13" Stretch="Fill" Fill="{DynamicResource SecundaryTitleColor}" HorizontalAlignment="Left" Margin="0,0,5,0"  Data="{DynamicResource manoapuntandoarriba}"/>
                    <TextBlock Text="Haga doble-click para consultar el trámite" Foreground="{DynamicResource SecundaryTitleColor}" VerticalAlignment="Center" HorizontalAlignment="Left"/>


                </StackPanel>
                <Button  Grid.Column="1"  x:Name="FiltrarButton" Style="{StaticResource OmitirComparecienteButtonsStyle}" VerticalAlignment="Center" Width="100" HorizontalAlignment="Right" Margin="0,0,5,0"  Click="FiltrarButton_Click" >
                    <StackPanel Orientation="Horizontal">
                        <Path x:Name="dropdownIcon" Grid.Column="0" Width="13" Height="13" Stretch="Fill" Fill="{StaticResource PrimaryColor }" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,5,0"  Data="{DynamicResource arrowdownfiltro}" />
                        <TextBlock Text="Filtrar" VerticalAlignment="Center"/>
                    </StackPanel>
                </Button>
            </Grid>
            <Grid Grid.Row="2" Margin="15" HorizontalAlignment="Stretch">
                    <ListView
                        x:Name="BandejaGrid"
                        ItemsSource="{Binding Tramites}"
                        VirtualizingPanel.VirtualizationMode="Recycling"
                        Foreground="{StaticResource TextPrimaryColorUCNC}" SelectionChanged="BandejaGrid_SelectionChanged">
                        <ListView.View>
                            <GridView
                                x:Name="gridView"
                                >
                                <GridViewColumn 
                                    DisplayMemberBinding="{Binding Id}"
                                    Width="120" >
                                    <GridViewColumnHeader>
                                        Consecutivo
                                        <GridViewColumnHeader.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Ascending" />
                                                <MenuItem Header="Descending" />
                                            </ContextMenu>
                                        </GridViewColumnHeader.ContextMenu>
                                    </GridViewColumnHeader>
                                </GridViewColumn>
                                <GridViewColumn 
                                    DisplayMemberBinding="{Binding TipoTramite}"
                                    Width="120" >
                                    <GridViewColumnHeader>
                                        Tipo de Trámite
                                        <GridViewColumnHeader.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Ascending" />
                                                <MenuItem Header="Descending" />
                                            </ContextMenu>
                                        </GridViewColumnHeader.ContextMenu>
                                    </GridViewColumnHeader>
                                </GridViewColumn>
                                <GridViewColumn 
                                    DisplayMemberBinding="{Binding Comparecientes}"
                                    Width="120">
                                    <GridViewColumnHeader>
                                        Comparecientes
                                        <GridViewColumnHeader.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Ascending" />
                                                <MenuItem Header="Descending" />
                                            </ContextMenu>
                                        </GridViewColumnHeader.ContextMenu>
                                    </GridViewColumnHeader>
                                </GridViewColumn>
                                <GridViewColumn 
                                    DisplayMemberBinding="{Binding DocCompareciente}"
                                    Width="120" >
                                    <GridViewColumnHeader>
                                        Documento
                                        <GridViewColumnHeader.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Ascending" />
                                                <MenuItem Header="Descending" />
                                            </ContextMenu>
                                        </GridViewColumnHeader.ContextMenu>
                                    </GridViewColumnHeader>
                                </GridViewColumn>
                                <GridViewColumn 
                                    DisplayMemberBinding="{Binding Fecha}"
                                    Width="120" >
                                    <GridViewColumnHeader>
                                        Fecha
                                        <GridViewColumnHeader.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Ascending" />
                                                <MenuItem Header="Descending" />
                                            </ContextMenu>
                                        </GridViewColumnHeader.ContextMenu>
                                    </GridViewColumnHeader>
                                </GridViewColumn>
                                <GridViewColumn 
                                    DisplayMemberBinding="{Binding Biometria}"
                                    Width="120" >
                                    <GridViewColumnHeader>
                                        Biometria
                                        <GridViewColumnHeader.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Ascending" />
                                                <MenuItem Header="Descending" />
                                            </ContextMenu>
                                        </GridViewColumnHeader.ContextMenu>
                                    </GridViewColumnHeader>
                                </GridViewColumn>
                                <GridViewColumn 
                                    DisplayMemberBinding="{Binding Proceso}"
                                    Width="120">
                                    <GridViewColumnHeader>
                                        Proceso
                                        <GridViewColumnHeader.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Ascending" />
                                                <MenuItem Header="Descending" />
                                            </ContextMenu>
                                        </GridViewColumnHeader.ContextMenu>
                                    </GridViewColumnHeader>
                                </GridViewColumn>
                                <GridViewColumn 
                                    DisplayMemberBinding="{Binding Estado}"
                                    Width="120">
                                    <GridViewColumnHeader>
                                        Estado
                                        <GridViewColumnHeader.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Ascending" />
                                                <MenuItem Header="Descending" />
                                            </ContextMenu>
                                        </GridViewColumnHeader.ContextMenu>
                                    </GridViewColumnHeader>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                        
                        
                        
                        
                        
                    </ListView>
            </Grid>
        </Grid>
        <Grid x:Name="DocumentoGrid" Visibility="Collapsed">
            <Grid.RowDefinitions>
                <RowDefinition Height="60"/>
                <RowDefinition Height="35"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="35"/>
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Text="Revisión del documento" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="15,0,0,0" Style="{StaticResource TituloTextBlock}"/>

            <Grid Grid.Row="1" Background="{StaticResource TitleBackgroundColor}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>

                </Grid.ColumnDefinitions>

                <Button  Grid.Column="0"  x:Name="RegresarButton" Style="{StaticResource OmitirComparecienteButtonsStyle}" VerticalAlignment="Center" Width="250" HorizontalAlignment="Left" Margin="15,0,5,0"  Click="RegresarButton_Click" >
                    <StackPanel Orientation="Horizontal">
                        <Path x:Name="RegresarIcon" Grid.Column="0" Width="13" Height="13" Stretch="Fill" Fill="{StaticResource PrimaryGrayColor }" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,5,0"  Data="{DynamicResource volverabandeja}" />
                        <TextBlock Text="Regresar al listado de tramites" VerticalAlignment="Center"/>
                    </StackPanel>
                </Button>
            </Grid>
            <Grid Grid.Row="2" Margin="15" HorizontalAlignment="Stretch">
                    <Frame x:Name="DocumentosFrame"  NavigationUIVisibility="Hidden"></Frame>
                <!--<WebBrowser x:Name="DocumentoBrowser"></WebBrowser>-->
            </Grid>

        </Grid>
        </Grid>
    </Border>
</Page>


AutorizadosPage.xaml.cs

C#
BandejaAutorizadosVM VM;
        FiltroTramites filtroTramites = new FiltroTramites();
        public autorizadosPage()
        {
            InitializeComponent();
            VM = new BandejaAutorizadosVM();
            primeraCarga();
            //pruebaconsulta();
        }

        private void RefrescarButton_Click(object sender, RoutedEventArgs e)
        {

        }

        private void FiltrarButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new FiltrosModal();
            if (dialog.ShowDialog() == false)
            {
                if (dialog.filtro.NotariaId != 0)
                {
                    filtroTramites = dialog.filtro;
                    VM = new BandejaAutorizadosVM(filtroTramites);
                    BandejaGrid.ItemsSource = null;
                    BandejaGrid.ItemsSource = VM.Tramites;
                    
                }
                dialog.Close();
                
            }
        }
        private void primeraCarga() 
        {
            filtroTramites = VM.FiltroBusqueda;
            BandejaGrid.ItemsSource = null;
            BandejaGrid.ItemsSource = VM.Tramites;
            
        }


        private void CargarPDF(ActaNotarialModel Archivo)
        {
            byte[] bytes = System.Convert.FromBase64String(Archivo.Archivo);
            string rutaapdf = DocumentosHandler.SaveByteArrayToFile(bytes);
            WebBrowser DocumentoBrowser = new WebBrowser();
            DocumentoBrowser.Navigate("file:///" + rutaapdf);
            DocumentosFrame.Content = DocumentoBrowser;
            TramitesGrid.Visibility = Visibility.Collapsed;
            DocumentoGrid.Visibility = Visibility.Visible;
        }
        private void CargarPDF2(ActaNotarialModel Archivo)
        {

            DocumentosFrame.Navigate(new RevisionDocumentoPage(Archivo));
            TramitesGrid.Visibility = Visibility.Collapsed;
            DocumentoGrid.Visibility = Visibility.Visible;
        }
        private void RegresarButton_Click(object sender, RoutedEventArgs e)
        {
            TramitesGrid.Visibility = Visibility.Visible;
            DocumentoGrid.Visibility = Visibility.Collapsed;
            WebBrowser browser = DocumentosFrame.Content as WebBrowser;
            browser.Dispose();
            DocumentosFrame.Content = null;
            VM = new BandejaAutorizadosVM(filtroTramites);
            BandejaGrid.ItemsSource = null;
            BandejaGrid.ItemsSource = VM.Tramites;

        }

        private void BandejaGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListaTramitePendienteReturnDTO seleccion = new ListaTramitePendienteReturnDTO();
            if (BandejaGrid.SelectedItem != null)
            {

       
            seleccion = BandejaGrid.SelectedItem as ListaTramitePendienteReturnDTO;
                long idtramite = seleccion.Id;
                BandejasHelpers consulta = new BandejasHelpers();
                ErroresDTO erroresDTO = new ErroresDTO();
                ActaNotarialModel resultado = new ActaNotarialModel();
                resultado = consulta.ObtenerActaNotarial(GLOBALS.UserLogueado.Token, idtramite, out erroresDTO);

                //var dialog = new RevisionDocumentoWindow(resultado);
                //if (dialog.ShowDialog() == false)
                //{

                //}
                //else
                //{

                //}
                if (resultado != null)
                {
                    CargarPDF2(resultado);
                }
                else
                {
                    // Errores
                }


            }
        }


This is my filter is Window so here the click get stucked and cant see the datepicker after charge the pdf

FiltroModal.xaml
<Window x:Class="Olimpia.AppWindows.Cliente.View.Bandejas.FiltrosModal"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ui="http://schemas.modernwpf.com/2019"
        xmlns:local="clr-namespace:Olimpia.AppWindows.Cliente.View.Bandejas"
        mc:Ignorable="d"
        Title="FiltrosModal" Height="450" Width="357" AllowsTransparency="True" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="Transparent" ResizeMode="NoResize" WindowState="Normal">
    <Border CornerRadius="8" BorderThickness="1" BorderBrush="{DynamicResource ButtonBackgroundColor}"  Background="{DynamicResource SecundaryBackgroundColor}">
        <Grid >
            <Grid.RowDefinitions>
                <RowDefinition Height="15*"/>
                <RowDefinition Height="65*"/>
                <RowDefinition Height="20*"/>
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0"  Text="Filtrar Resultados" VerticalAlignment="Center" HorizontalAlignment="left" TextAlignment="left" Margin="15,0,0,0" FontWeight="Bold" FontSize="16" Foreground="{StaticResource TextPrimaryColor}" Width="218" />
            <Grid x:Name="GridGeneral" Grid.Row="1" Grid.RowSpan="2">
                <StackPanel HorizontalAlignment="Center">
                    <StackPanel Orientation="Horizontal" >
                        <StackPanel Orientation="Vertical" Margin="0" Width="138" >
                            <Label Content="Fecha Inicial"  Foreground="{StaticResource TextPrimaryColor}"/>
                        <DatePicker
                    x:Name="FechaInicialDatepicker"
                    Margin="0,5,0,5" VerticalContentAlignment="Center" HorizontalAlignment="Stretch" Foreground="{StaticResource TextPrimaryColor}" BorderBrush="{StaticResource ButtonBackgroundColor}"
                    ui:ControlHelper.PlaceholderText="Fecha Inicial"
                    MaxHeight="40" SelectedDateChanged="FechaSeleccionada_SelectedDateChanged" />
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Margin="0">
                            <Label Content="Fecha Inicial" Foreground="{StaticResource TextPrimaryColor}" />
                            <DatePicker
                    x:Name="FechaFinalDatepicker"
                    Margin="5,5,0,5" VerticalContentAlignment="Center" HorizontalAlignment="Stretch" Foreground="{StaticResource TextPrimaryColor}" BorderBrush="{StaticResource ButtonBackgroundColor}"
                    ui:ControlHelper.PlaceholderText="Fecha final"
                    MaxHeight="40" SelectedDateChanged="FechaSeleccionada_SelectedDateChanged" Width="134"/>
                        </StackPanel>
                    </StackPanel>
                    <Label Content="NUIP Operador" Margin="5,5" Foreground="{StaticResource TextPrimaryColor}"/>
                    <TextBox x:Name="NUIPOperadorTextbox" Grid.Column="1" ui:ControlHelper.PlaceholderText="Nombres en el documento"  HorizontalAlignment="Stretch"  Margin="0,5" VerticalContentAlignment="Center" Foreground="{StaticResource TextPrimaryColor}" BorderBrush="{StaticResource ButtonBackgroundColor}" TextAlignment="Left"  />
                    <Label Content="NUIP Compareciente" Margin="5,5" Foreground="{StaticResource TextPrimaryColor}"/>
                    <TextBox x:Name="NUIPComparecienteTextbox" Grid.Column="1" ui:ControlHelper.PlaceholderText="Nombres en el documento"  HorizontalAlignment="Stretch"  Margin="0,5" VerticalContentAlignment="Center" Foreground="{StaticResource TextPrimaryColor}" BorderBrush="{StaticResource ButtonBackgroundColor}" TextAlignment="Left"  />
                    <Label Content="N# Tramite" Margin="5,5" Foreground="{StaticResource TextPrimaryColor}"/>
                    <TextBox x:Name="NtramiteTextbox" Grid.Column="1" ui:ControlHelper.PlaceholderText="Nombres en el documento"  HorizontalAlignment="Stretch"  Margin="0,5" VerticalContentAlignment="Center" Foreground="{StaticResource TextPrimaryColor}" BorderBrush="{StaticResource ButtonBackgroundColor}" TextAlignment="Left" PreviewTextInput="NTramiteTextBox_PreviewTextInput"  />
                    <Button x:Name="LimpiarFiltrosButton" Style="{StaticResource OtherLinkCerrarSesionButtonsStyle}"  VerticalAlignment="Center" HorizontalAlignment="Left"  Width="40" Height="32" Margin="5,0,0,0" Click="LimpiarFiltrosButton_Click" >
                        <TextBlock  Text="Limpiar" TextAlignment="Left" TextDecorations="Underline"/>
                    </Button>
                    <Grid Margin="0,20">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="140"/>
                            <ColumnDefinition Width="140"/>
                        </Grid.ColumnDefinitions>

                        
                        <Button x:Name="CancelarButton" Grid.Column="1" Style="{StaticResource CancelarTramiteButtonsStyle}"  VerticalAlignment="Center" Content="Cancelar" HorizontalAlignment="Right" Width="129" Height="32" Margin="5,0,5,0" Click="CancelarButton_Click" />
                        <Button x:Name="FiltrarButton" Grid.Column="2" Style="{StaticResource PrimaryButtonsStyle}"  VerticalAlignment="Center" Content="Filtrar" HorizontalAlignment="Right" Width="129" Height="32" Margin="5,0,5,0" Click="FiltrarButton_Click" />

                    </Grid>
                </StackPanel>
                
            </Grid>
          
        </Grid>
    </Border>
</Window>

FiltrosModal.xaml.cs

C#
public FiltroTramites filtro = new FiltroTramites();
        public FiltrosModal()
        {
                InitializeComponent();
            FechaFinalDatepicker.DisplayDateStart = DateTime.Today.AddDays(-90);
            FechaFinalDatepicker.DisplayDateEnd = DateTime.Today;
            FechaInicialDatepicker.DisplayDateStart = DateTime.Today.AddDays(-91);
            FechaInicialDatepicker.DisplayDateEnd = DateTime.Today.AddDays(-1);
            FechaInicialDatepicker.SelectedDate = DateTime.Today.AddDays(-7);
            FechaFinalDatepicker.SelectedDate = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
            
        }
        //protected override void OnDeactivated(EventArgs e)
        //{
        //    base.OnDeactivated(e);
        //    Close();
        //}
        // Seteo de rango maximo de fechas
        private void FechaSeleccionada_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            DateTime fechainicial;
            DateTime fechahoy;
            DateTime fechafinal;
            DatePicker datePicker = sender as DatePicker;
            string nombre = datePicker.Name;
            switch (nombre)
            {
                case "FechaInicialDatepicker":
                    
                    fechainicial = (DateTime)datePicker.SelectedDate;
                    fechafinal = fechainicial.AddDays(90);
                    fechahoy = DateTime.Today;
                    if (fechafinal > fechahoy)
                    {
                        fechafinal = fechahoy;
                        FechaFinalDatepicker.DisplayDateStart = fechainicial.AddDays(+1);
                        FechaFinalDatepicker.DisplayDateEnd = DateTime.Today;
                    }
                    else
                    {
                        FechaFinalDatepicker.DisplayDateStart = fechainicial.AddDays(+1);
                        FechaFinalDatepicker.DisplayDateEnd = fechafinal;
                    }
                    
                    break;
                case "FechaFinalDatepicker":
                   
                        fechafinal = (DateTime)datePicker.SelectedDate;
                        fechainicial = fechafinal.AddDays(-90);
                        FechaInicialDatepicker.DisplayDateStart = fechainicial;
                        FechaInicialDatepicker.DisplayDateEnd = fechafinal.AddDays(-1);
                    
                    break;
                default:
                    break;
               
            }
        }

        private void LimpiarFiltrosButton_Click(object sender, RoutedEventArgs e)
        {
            LimpiarCampos();
        }

        private void FiltrarButton_Click(object sender, RoutedEventArgs e)
        {
            ValidacionCampos();
            DialogResult = false;
            //Close();
        }

        private void CancelarButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            //Close();
        }

        private void LimpiarCampos()
        {
            NUIPComparecienteTextbox.Text = "";
            NUIPOperadorTextbox.Text = "";
            NtramiteTextbox.Text = "";
            FechaFinalDatepicker.SelectedDate = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
            FechaInicialDatepicker.SelectedDate = DateTime.Today.AddDays(-7);
            FechaFinalDatepicker.DisplayDateStart = DateTime.Today.AddDays(-90);
            FechaFinalDatepicker.DisplayDateEnd = DateTime.Today;
            FechaInicialDatepicker.DisplayDateStart = DateTime.Today.AddDays(-91);
            FechaInicialDatepicker.DisplayDateEnd = DateTime.Today.AddDays(-1);
            FechaFinalDatepicker.SelectedDate = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
            FechaInicialDatepicker.SelectedDate = DateTime.Today.AddDays(-7);
        }
        private void ValidacionCampos()
        {
            // Fechas por defecto
            DateTime fechafinal= DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
            DateTime fechainicial= DateTime.Today.AddDays(-7);
            if ((FechaInicialDatepicker.SelectedDate==null && FechaFinalDatepicker.SelectedDate==null))
            {
                fechafinal = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
                fechainicial = DateTime.Today.AddDays(-7);
                    string error = "El rango de fechas por defecto es de 7 dias desde el dia actual.";
                    new CustomToastNotifications("Seleccion de Fechas", MessageType.Warning, error);
            }
            else
            {
                if(FechaInicialDatepicker.SelectedDate != null && FechaFinalDatepicker.SelectedDate != null)
                {
                    fechafinal = (DateTime)FechaFinalDatepicker.SelectedDate;
                    fechafinal = fechafinal.AddHours(23).AddMinutes(59).AddSeconds(59);
                    fechainicial = (DateTime)FechaInicialDatepicker.SelectedDate;
                }
                if (FechaInicialDatepicker.SelectedDate== null && FechaFinalDatepicker.SelectedDate!=null)
                {
                    fechafinal = (DateTime)FechaFinalDatepicker.SelectedDate;
                    fechafinal = fechafinal.AddHours(23).AddMinutes(59).AddSeconds(59);
                    fechainicial = fechafinal.AddDays(-7).AddHours(0).AddMinutes(0).AddSeconds(0);
                    string error = "Por defecto la busqueda sera de los ultimos 7 dias desde la fecha final seleccionada.";
                    new CustomToastNotifications("Seleccion de fecha inicial", MessageType.Warning, error);
                }
                if (FechaFinalDatepicker.SelectedDate==null && FechaInicialDatepicker.SelectedDate!=null)
                {
                    fechainicial = (DateTime)FechaInicialDatepicker.SelectedDate;
                    fechafinal = fechainicial.AddDays(+7).AddHours(23).AddMinutes(59).AddSeconds(59);
                    string error = "Por defecto la busqueda sera los 7 dias consecutivos desde la fecha inicial seleccionada.";
                    new CustomToastNotifications("Seleccion de fecha inicial", MessageType.Warning, error);
                }
                
            }
               
                // Seteo de las fechas
                filtro.fechaFinal = fechafinal;
                filtro.fechaInicial = fechainicial;
                filtro.NotariaId = long.Parse(GLOBALS.NotariaUsuario.notariaId);




            if (NUIPComparecienteTextbox.Text=="")
            {
                filtro.NuipCompareciente = null;
            }
            else
            {
                filtro.NuipCompareciente = NUIPComparecienteTextbox.Text;
            }
            if (NUIPOperadorTextbox.Text == "")
            {
                filtro.NuipOperador = null;
            }
            else
            {
                filtro.NuipOperador = NUIPOperadorTextbox.Text;
            }
            if (NtramiteTextbox.Text == "")
            {
                filtro.TramiteId = 0;
            }
            else
            {
                filtro.TramiteId = long.Parse(NtramiteTextbox.Text);
            }
                // Seteo de paginas y cantidad de registros
                filtro.NumeroPagina = 1;
                filtro.RegistrosPagina = 20;

            
        }


        private static readonly Regex _regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
        private static bool IsTextAllowed(string text)
        {
            return !_regex.IsMatch(text);
        }

        private void NTramiteTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            e.Handled = !IsTextAllowed(e.Text);
        }


What I have tried:

i tryed on another page
i tryed on another windows
i tryed on with DataGrid and the problem remains
i tried change webbrowser to a frame and dispose the webbrowser
i tried
Posted
Updated 18-May-22 14:20pm

1 solution

There is too much code here to help you. Also, your comment "but after i redirect and go back the controls of filter datepicker didnt work" does not tell us what is happening. HOW does it not work? Do you get an error message? Does the listview not show? Does the Listview show but no data?

When you use a Frame or ContentControl, the Page/Content in that control only exists for the time that it is displayed. If you want persistance, then you need to implement a persistance system, ususally a stattic class or written to a storage are in memory or file.

To quote the official documentation: Frame Class (System.Windows.Controls) | Microsoft Docs[^]
Frame does not store an instance of a content object in navigation history. Instead, Frame creates a new instance of the content object each time it is navigated to by using navigation history. This behavior is designed to avoid excessive memory consumption when large numbers and large pieces of content are being navigated to. Consequently, the state of the content is not remembered from one navigation to the next. However, WPF provides several techniques by which you can store a state for a piece of content in navigation history.

Without specifics, I can't really give much more information. I won't be trying to put your code in a test project to see.

Hope this helps!
 
Share this answer
 
v2
Comments
Member 15067932 19-May-22 8:58am    
Well after i load the pdf on the frame and shows .. the datepicker calendar doesnt show on my filter.. even if i go to another module and and try to start a new seccion redirection itself doesnt work to child modules im not looking to store navigation history dont need that.. I need to know what is happening with the controls when im on the webbrowser showing the pdf .. i tried show in new windows, show in same page without redirection, show with redirection , change listview to datagrid and keep the same problem.. i think that the problem is the webbrowser showing the pdf but im not sure... im gonna try now make the user open the file in windows without opening in webbrowser inside my aplications and see what happen!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900