public bool PrintVale(OfflineSaleViewModel vale)
        {
            PrintDialog pDialog = new PrintDialog();
            pDialog.UserPageRangeEnabled = false;

            // Display the dialog. This returns true if the user presses the Print button.
            Nullable<Boolean> print = pDialog.ShowDialog();
            if (print == true)
            {
                ValeToPrint control = new ValeToPrint();
                control.DataContext = vale;

                Size sz = new Size(pDialog.PrintableAreaWidth, pDialog.PrintableAreaHeight);

                // arrange
                control.Measure(sz);
                control.Arrange(new Rect(sz));
                control.UpdateLayout();

                Size finalSize = new Size(control.DesiredSize.Width, control.DesiredSize.Height);

                control.Measure(finalSize);
                control.Arrange(new Rect(finalSize));
                control.UpdateLayout();

                pDialog.PrintVisual(control, "Imprimiendo vale");

                return true;
            }

            return false;
        }
        //#region Filter

        //private void KitchenProductsFilter(object sender, FilterEventArgs e)
        //{
        //    OfflineLineItemViewModel lineitem = (OfflineLineItemViewModel)e.Item;

        //    e.Accepted = lineitem.Product.IsProduced;          
        //}

        //#endregion

        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue is OfflineSaleViewModel)
            {
                OfflineSaleViewModel viewmodel = (OfflineSaleViewModel)e.NewValue;
                viewmodel.LineItemAdded += new EventHandler(viewmodel_LineItemAdded);
            }
            else if (e.OldValue is OfflineSaleViewModel)
            {
                OfflineSaleViewModel viewmodel = (OfflineSaleViewModel)e.OldValue;
                viewmodel.LineItemAdded -= viewmodel_LineItemAdded;
            }
        }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     OfflineSaleViewModel vale = (OfflineSaleViewModel)this.DataContext;
     PrintVale(vale);
 }