Archive for febrero, 2012

Sacar ventana de WPF en otro monitor

Desde el evento Loaded de la ventana llamamos al siguiente código

privatevoid ShowInMonitor(int screen)

{

this.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;

this.Left = System.Windows.Forms.Screen.AllScreens[screen].Bounds.Left;

this.Top = System.Windows.Forms.Screen.AllScreens[screen].Bounds.Top;

this.Width = System.Windows.Forms.Screen.AllScreens[screen].Bounds.Width;

this.Height = System.Windows.Forms.Screen.AllScreens[screen].Bounds.Height;

this.WindowState = WindowState.Maximized;

this.Topmost = true;

WindowState = System.Windows. WindowState.Maximized;

this.Show();

}

 

Acceder a un control definido en una plantilla WPF

Supongamos que tenemos

 <ContentControl Name="cntNuevoProducto" Margin="10,10,20,10"
                        ContentTemplate="{StaticResource itemVentaDT}"></ContentControl>
Queremos acceder a los controles definidos en la DataTemplate "itemVentaDT"
 DependencyObject oooo=VisualTreeHelper.GetChild(cntNuevoProducto,0);
 ContentPresenter cp=(ContentPresenter)oooo;
 TextBox n = (TextBox)cntNuevoProducto.ContentTemplate.FindName("txtboxDescripItem",cp );
Powered by WordPress | Compare the Best Cell Phones at Bestincellphones.com. | Thanks to CD Rates, 0 credit cards and Home Information Packs