Paulagier
asked on
WPF user control poped up from a window
Helo experts
It ought to be silly but i am scratching my head in this problem
I want to open a custom user control from inside a wpf window by clicking a check box
Help me please
Here comes my code
Main window is named testrecupdata.xaml
User control is named Rapporteur_UC.xaml
It ought to be silly but i am scratching my head in this problem
I want to open a custom user control from inside a wpf window by clicking a check box
Help me please
Here comes my code
Main window is named testrecupdata.xaml
User control is named Rapporteur_UC.xaml
x:Class="Consultation_Rachis.testrecupdata"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="testrecupdata" Height="300" Width="300">
<Grid>
<TextBlock Name ="Value_Lasegue" HorizontalAlignment="Left" GotFocus="Value_Lasegue_GotFocus" Margin="179,115,0,0" TextWrapping="Wrap" Text="Resu_Lasegue" VerticalAlignment="Top"/>
<CheckBox Name="LasegueOK" Content="Lasegue" IsChecked="False" Checked="LasegueOK_Checked" Unchecked="LasegueOK_Unchecked" HorizontalAlignment="Left" Margin="170,51,0,0" VerticalAlignment="Top"/>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
u
namespace Consultation_Rachis
{
/// <summary>
/// Interaction logic for testrecupdata.xaml
/// </summary>
public partial class testrecupdata : Window
{
public string resu_lasegue = "0";
Rapporteur_UC rapporteur = new Rapporteur_UC();
string resu_rapporteur = "Resources\\Rapporteur.txt";
public testrecupdata()
{
InitializeComponent();
}
private void LasegueOK_Checked(object sender, RoutedEventArgs e)
{
rapporteur.Visibility = Visibility.Visible;
}
private void LasegueOK_Unchecked(object sender, RoutedEventArgs e)
{
//rapporteur.Visibility = System.Windows.Visibility.Hidden;
}
private void Value_Lasegue_GotFocus(object sender, RoutedEventArgs e)
{
using (System.IO.StreamReader file = new System.IO.StreamReader(resu_rapporteur))
Value_Lasegue.Text = file.ReadLine();
}
}
}
UserControl x:Class="Consultation_Rachis.Rapporteur_UC"
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"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="500" Visibility="Collapsed" BorderBrush="#FFF1EBEB" Background="#FFF0E5E5">
<Grid>
<TextBlock Name="txbNameAngleValue" Text=" any content" />
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Consultation_Rachis
{
/// <summary>
/// Interaction logic for Rapporteur_UC.xaml
/// logic from http://stackoverflow.com/questions/5336131/wpf-math-for-semi-circle-using-arcsegment-between-two-arbitrary-points
/// </summary>
public partial class Rapporteur_UC : UserControl
{
public string txbfinal = "";
string FileName = "Resources\\Rapporteur.txt";
public Rapporteur_UC()
{
InitializeComponent();
}
// ...........
private void btnValidAngleRapp_Click(object sender, RoutedEventArgs e)
{
testrecupdata origine = new testrecupdata();
origine.Value_Lasegue.Focus();
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.