Displaying a form in a window panel in WPF application - c#

So I am created a window with a space to display and show each form, depending on which button click, the issue is I cant seem to find any solution on how to have the form open in the specific window or in the panel of that specific window.
Is this even possible?
My Window design code is as follow:
Title="winHomeDash" Height="650" Width="950"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
AllowsTransparency="True"
materialDesign:ThemeAssist.Theme="Dark"
Background="{x:Null}" Loaded="BtnMenuShort_Click">
<materialDesign:Card UniformCornerRadius="15" Margin="25" Width="900" Height="600" Background="{DynamicResource ResourceKey=MaterialDesignDarkBackground}">
<materialDesign:Card UniformCornerRadius="15" HorizontalAlignment="Left" Width="225" Background="#0A1828">
<DockPanel Width="225" Height="600">
<StackPanel Height="155" VerticalAlignment="Top" Width="225">
<Image Height="50" Width="50" Margin="0 15 0 15" Source="/UserPic.png"/>
<Label Name="lblName" BorderThickness="0" FontFamily="Arial" FontWeight="Bold" FontSize="17" Margin="0 0 0 5" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="#FF2372FA" Height="24" Loaded="Window_Loaded"/>
<Label x:Name="lblDateTime" Content="" FontFamily="Arial" FontWeight="SemiBold" FontSize="12" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="#FF2372FA" Margin="0 0 0 18" Height="22" Width="225" Loaded="LblDateTime_Loaded"/>
<Rectangle Name="rec1" Height="7" Fill="#FF2372FA"/>
</StackPanel>
<materialDesign:Card Name="card2" Width="210" UniformCornerRadius="15" Height="445" Background="{DynamicResource ResourceKey=MaterialDesignDarkBackground}" Foreground="White" Margin="-210,155,0,0">
<StackPanel VerticalAlignment="Center" Height="445" Name="stpnlMenu">
<Button x:Name="btnCollapse" Width="15" Height="30" BorderBrush="{x:Null}" Foreground="{x:Null}" FlowDirection="RightToLeft" Margin="195,207.5,0,0" Click="BtnMenuShort_Click">
<Button.Background>
<ImageBrush ImageSource="/more_than_25px.png"/>
</Button.Background>
</Button>
<Button x:Name="btnMenu" Content="MENU" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,-227.5,0,0" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" Click="BtnMenuShort_Click" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu"/>
<Button x:Name="btnHome" Content="HOME" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,-187.5,0,0" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu"/>
<Button x:Name="btnFuel" Content="FUEL" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,-147.5,0,0" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" RenderTransformOrigin="-0.836,17.714" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu" Click="BtnFuel_Click"/>
<Button x:Name="btnTyres" Content="TYRES" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,-122.5,0,0" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" RenderTransformOrigin="-0.836,17.714" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu"/>
<Button x:Name="btnService" Content="SERVICE" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,-97.5,0,0" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" RenderTransformOrigin="-0.836,17.714" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu"/>
<Button x:Name="btnBags" Content="WASTE BAGS" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,-72.5,0,0" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" RenderTransformOrigin="-0.836,17.714" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu"/>
<Button x:Name="btnExpand" Width="15" Height="30" BorderBrush="{x:Null}" Foreground="{x:Null}" FlowDirection="LeftToRight" Margin="25,-30,0,0" Click="BtnMenuShort_Click" Visibility="Hidden">
<Button.Background>
<ImageBrush ImageSource="/more_than_25px.png"/>
</Button.Background>
</Button>
<Button x:Name="btnChat" Content="QUICK CHAT" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,122.5,0,0" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" RenderTransformOrigin="-0.836,17.714" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu"/>
<Button x:Name="btnHelp" Content="SUPPORT" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,5,0,0" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" RenderTransformOrigin="-0.836,17.714" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu"/>
<Button x:Name="btnLogOut" Content="LOG OUT" HorizontalContentAlignment="Left" Width="160" Height="20" Margin="0,5,0,20" FontFamily="Arial" FontSize="10" FontWeight="SemiBold" Background="{x:Null}" BorderBrush="{x:Null}" RenderTransformOrigin="-0.836,17.714" Click="BtnLogOut_Click" VerticalAlignment="Top" Cursor="Hand" Tag="tagMenu"/>
</StackPanel>
</materialDesign:Card>
<StackPanel Width="30" Height="445" Margin="-400,155,0,0" Background="#0A1828">
<Rectangle Name="rec2" Height="10"/>
<Button Name="btnMenuShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Click="BtnMenuShort_Click" Cursor="Hand">
<Button.Background>
<ImageBrush ImageSource="/menu_30px.png" Stretch="Uniform"/>
</Button.Background>
</Button>
<Rectangle Name="rec3" Height="20"/>
<Button Name="btnHomeShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Width="20" Cursor="Hand">
<Button.Background>
<ImageBrush ImageSource="/home_30px.png" Stretch="Fill"/>
</Button.Background>
</Button>
<Rectangle Name="rec4" Height="20"/>
<Button Name="btnFuelShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Width="20" Margin="0,0,0,5" Cursor="Hand" Click="BtnFuel_Click">
<Button.Background>
<ImageBrush ImageSource="/gas_station_30px.png" Stretch="Fill"/>
</Button.Background>
</Button>
<Button Name="btnTyresShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Width="20" Margin="0,0,0,5" Cursor="Hand">
<Button.Background>
<ImageBrush ImageSource="/wheel_30px.png" Stretch="Fill"/>
</Button.Background>
</Button>
<Button Name="btnServiceShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Width="20" Margin="0,0,0,5" Cursor="Hand">
<Button.Background>
<ImageBrush ImageSource="/maintenance_30px.png" Stretch="Fill"/>
</Button.Background>
</Button>
<Button Name="btnBagsShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Width="20" Margin="0,0,0,5" Cursor="Hand">
<Button.Background>
<ImageBrush ImageSource="/waste_30px.png" Stretch="Fill"/>
</Button.Background>
</Button>
<Rectangle Name="rec5" Height="170"/>
<Button Name="btnChatShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Width="20" Margin="0,0,0,5" Cursor="Hand">
<Button.Background>
<ImageBrush ImageSource="/chat_30px.png" Stretch="Fill"/>
</Button.Background>
</Button>
<Button Name="btnHelpShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Width="20" Margin="0,0,0,5" Cursor="Hand">
<Button.Background>
<ImageBrush ImageSource="/help_30px.png" Stretch="Fill"/>
</Button.Background>
</Button>
<Button Name="btnLogOutShort" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="20" Width="20" Margin="0,0,0,5" Click="BtnLogOut_Click" Cursor="Hand">
<Button.Background>
<ImageBrush ImageSource="/exit_sign_30px.png" Stretch="Fill"/>
</Button.Background>
</Button>
<Rectangle Name="rec6" Height="10"/>
</StackPanel>
<materialDesign:Clock Name="clClock" Width="675" Height="22" FontFamily="Arial" FontWeight="SemiBold" FontSize="10" Foreground="White" Margin="0,578,0,0"/>
<Grid Width="645" Height="550" Margin="0,25,25,25" Name="stackForms">
</Grid>
</DockPanel>
</materialDesign:Card>
</materialDesign:Card>
The place for the grid is where I want the form to be displayed.
The Window cs code is as follows:
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;
using System.Windows.Forms;
using System.Configuration;
using Application = System.Windows.Application;
namespace SolAquaPro
{
/// <summary>
/// Interaction logic for winHomeDash.xaml
/// </summary>
public partial class WinHomeDash : Window
{
public WinHomeDash()
{
InitializeComponent();
}
private void LblDateTime_Loaded(object sender, RoutedEventArgs e)
{
}
private void BtnLogOut_Click(object sender, RoutedEventArgs e)
{
this.Close();
Window main = new MainWindow();
main.Show();
}
public void BtnMenuShort_Click(object sender, RoutedEventArgs e)
{
if ((card2.Visibility == Visibility.Visible) && (btnCollapse.Visibility == Visibility.Visible))
{
card2.Width = 45;
card2.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
btnBags.Visibility = Visibility.Hidden;
btnChat.Visibility = Visibility.Hidden;
btnFuel.Visibility = Visibility.Hidden;
btnHome.Visibility = Visibility.Hidden;
btnMenu.Visibility = Visibility.Hidden;
btnLogOut.Visibility = Visibility.Hidden;
btnService.Visibility = Visibility.Hidden;
btnHelp.Visibility = Visibility.Hidden;
btnTyres.Visibility = Visibility.Hidden;
btnCollapse.Visibility = Visibility.Hidden;
btnExpand.Visibility = Visibility.Visible;
}
else
{
if ((card2.Visibility == Visibility.Visible) && (btnCollapse.Visibility == Visibility.Hidden))
{
card2.Width = 210;
card2.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
btnBags.Visibility = Visibility.Visible;
btnChat.Visibility = Visibility.Visible;
btnFuel.Visibility = Visibility.Visible;
btnHome.Visibility = Visibility.Visible;
btnMenu.Visibility = Visibility.Visible;
btnLogOut.Visibility = Visibility.Visible;
btnService.Visibility = Visibility.Visible;
btnHelp.Visibility = Visibility.Visible;
btnTyres.Visibility = Visibility.Visible;
btnCollapse.Visibility = Visibility.Visible;
btnExpand.Visibility = Visibility.Hidden;
}
}
}
public void Window_Loaded(object sender, RoutedEventArgs e)
{
lblName.Content = Application.Current.Resources["UserAssign"].ToString();
}
private void BtnFuel_Click(object sender, RoutedEventArgs e)
{
Form frmFuelDash = new FuelDash();
frmFuelDash.Show();
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
DragMove();
}
}
}
Thank you in advance

You could try to refer to the following code to see if it matches yours.
If you have any questions, please let me know.
Right-click the reference under the project and select Add Reference....
Check System.Windows.Forms and WindowsFormsIntegration and click OK.
Project structure:
MainWindow.xaml:
<DockPanel >
<Grid x:Name="grid" Background="LightYellow" Width="500" Height="400">
</Grid>
<StackPanel x:Name="sp1" Width="200" Height="100" Background="LightSkyBlue" >
<Button x:Name="btn1" Width="80" Height="30" Background="LightGray" Content="form1" Click="btn1_Click" />
<Button x:Name="btn2" Width="80" Height="30" Background="LightGray" Content="form2" Click="btn2_Click"/>
</StackPanel>
</DockPanel>
MainWindow.xaml.cs:
using System.Windows;
using System.Windows.Forms.Integration;
namespace WpfShowForm
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btn1_Click(object sender, RoutedEventArgs e)
{
Form1 f1 = new Form1();
f1.TopLevel = false;
WindowsFormsHost host1 = new WindowsFormsHost();
host1.Child=f1;
grid.Children.Add(host1);
}
private void btn2_Click(object sender, RoutedEventArgs e)
{
Form2 f2 = new Form2();
f2.TopLevel = false;
WindowsFormsHost host2 = new WindowsFormsHost();
host2.Child = f2;
grid.Children.Add(host2);
}
}
}
Add button in Form1:
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
}
The Result:

Related

How to span images over two buttons in 5x5 grid WPF C#

trying to get an image from image array to span over two buttons that I have set up in a 5x5 grid. Based on a randomly generated 2D grid, images are placed in places on the button grid. If a position in the array = 2 then a 2 square long image is to be placed and the same for r = 3.
//This is if button (1,1) is pressed
private void _1_1_Click(object sender, RoutedEventArgs e)
{
if (radar.IsChecked == true)
{
if (gridarray[0,0] == 1)
{
Random rnd = new Random();
int r = rnd.Next(0,3);
_1_1.Content = images[r];
streak.Content = streakn++;
}
if (gridarray[0,0] == 2 || gridarray[0,1] == 2)
{
Random rnd = new Random();
int r = rnd.Next(3, 5);
_1_1.Content = images[r];
streak.Content = streakn++;
}
if (gridarray[0,0] == 3 || gridarray[0,1] == 3 || gridarray[0,2] == 3)
{
Random rnd = new Random();
int r = rnd.Next(5, 7);
_1_1.Content = images[r];
streak.Content = streakn++;
}
}
// here is where the image array is defined
private void defineImages()
{
images[0].Source = new BitmapImage(new Uri("Resources/small1.png", UriKind.Relative));
images[1].Source = new BitmapImage(new Uri("Resources/small2.jpg", UriKind.Relative));
images[2].Source = new BitmapImage(new Uri("Resources/small3.png", UriKind.Relative));
images[3].Source = new BitmapImage(new Uri("Resources/medium-1.jpg", UriKind.Relative));
images[4].Source = new BitmapImage(new Uri("Resources/medium2.jpg", UriKind.Relative));
images[5].Source = new BitmapImage(new Uri("Resources/large1.png", UriKind.Relative));
images[6].Source = new BitmapImage(new Uri("Resources/large2.jpg", UriKind.Relative));
}
// This is some relevant xaml
<TextBlock Grid.Row="0" Grid.Column="0" Margin="5" FontSize="15">Fish Caught:</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0" Margin="5" FontSize="15">Guess Streak:</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0" Margin="5" FontSize="15">Fish in Water:</TextBlock>
<Label Grid.Row="0" Grid.Column="1" Margin="5" FontSize="20" x:Name="caught"></Label>
<Label Grid.Row="1" Grid.Column="1" Margin="5" FontSize="20" x:Name="streak"></Label>
<Label Grid.Row="2" Grid.Column="1" Margin="5" FontSize="20" x:Name="fishinwater"></Label>
<Label Grid.Row="0" Grid.Column="2" Content="Timer:" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="25"/>
<Label Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="0" Content="Tool Select:" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="25"/>
<RadioButton x:Name="rod" Grid.Row="1" Grid.Column="3" Content="Rod" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30"/>
<RadioButton x:Name="radar" Grid.Row="1" Grid.Column="4" Content="Radar" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30"/>
<Button x:Name="_1_1" Grid.Row="3" Grid.Column="0" Background="White" Click="_1_1_Click">
<Image x:Name="_1"/>
</Button>
<Button x:Name="_1_2" Grid.Row="3" Grid.Column="1" Background="White">
<Image x:Name="_1_2image"/>
</Button>
<Button x:Name="_1_3" Grid.Row="3" Grid.Column="2" Background="White">
<Image x:Name="_1_3image"/>
</Button>
<Button x:Name="_1_4" Grid.Row="3" Grid.Column="3" Background="White">
<Image x:Name="_1_4image"/>
</Button>
<Button x:Name="_1_5" Grid.Row="3" Grid.Column="4" Background="White">
<Image x:Name="_1_5image"/>
</Button>
<Button x:Name="_2_1" Grid.Row="4" Grid.Column="0" Background="White">
<Image x:Name="_2_1image"/>
</Button>
<Button x:Name="_2_2" Grid.Row="4" Grid.Column="1" Background="White">
<Image x:Name="_2_2image"/>
</Button>
<Button x:Name="_2_3" Grid.Row="4" Grid.Column="2" Background="White">
<Image x:Name="_2_3image"/>
</Button>
<Button x:Name="_2_4" Grid.Row="4" Grid.Column="3" Background="White">
<Image x:Name="_2_4image"/>
</Button>
<Button x:Name="_2_5" Grid.Row="4" Grid.Column="4" Background="White">
<Image x:Name="_2_5image"/>
</Button>
<Button x:Name="_3_1" Grid.Row="5" Grid.Column="0" Background="White">
<Image x:Name="_3_1image"/>
</Button>
<Button x:Name="_3_2" Grid.Row="5" Grid.Column="1" Background="White">
<Image x:Name="_3_2image"/>
</Button>
<Button x:Name="_3_3" Grid.Row="5" Grid.Column="2" Background="White">
<Image x:Name="_3_3image"/>
</Button>
<Button x:Name="_3_4" Grid.Row="5" Grid.Column="3" Background="White">
<Image x:Name="_3_4image"/>
</Button>
<Button x:Name="_3_5" Grid.Row="5" Grid.Column="4" Background="White">
<Image x:Name="_3_5image"/>
</Button>
<Button x:Name="_4_1" Grid.Row="6" Grid.Column="0" Background="White">
<Image x:Name="_4_1image"/>
</Button>
<Button x:Name="_4_2" Grid.Row="6" Grid.Column="1" Background="White">
<Image x:Name="_4_2image"/>
</Button>
<Button x:Name="_4_3" Grid.Row="6" Grid.Column="2" Background="White">
<Image x:Name="_4_3image"/>
</Button>
<Button x:Name="_4_4" Grid.Row="6" Grid.Column="3" Background="White">
<Image x:Name="_4_4image"/>
</Button>
<Button x:Name="_4_5" Grid.Row="6" Grid.Column="4" Background="White">
<Image x:Name="_4_5image"/>
</Button>
<Button x:Name="_5_1" Grid.Row="7" Grid.Column="0" Background="White">
<Image x:Name="_5_1image"/>
</Button>
<Button x:Name="_5_2" Grid.Row="7" Grid.Column="1" Background="White">
<Image x:Name="_5_2image"/>
</Button>
<Button x:Name="_5_3" Grid.Row="7" Grid.Column="2" Background="White">
<Image x:Name="_5_3image"/>
</Button>
<Button x:Name="_5_4" Grid.Row="7" Grid.Column="3" Background="White">
<Image x:Name="_5_4image"/>
</Button>
<Button x:Name="_5_5" Grid.Row="7" Grid.Column="4" Background="White">
<Image x:Name="_5_5image"/>
</Button>
<Label x:Name="timer" FontSize="30" Grid.RowSpan="2" Grid.Row="1" Grid.Column="2" Margin="5" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="0"/>
Ignore the image tags they are not in use images are going directly into buttons.

how to properly use item click in gridview

I have a gridview, which presents all of the users I have in my database, and their details, I want to be able, on the click of a user(on the gridview), that it's details will appear separately on the side of the grid view, and there I could change them accordingly. However, I'm not sure how to do so. I have the ItemClick event in my gridview, and It does recognize if I click on an item, but I don't know how to get that specific clicked user's details, for me to present them on the side. I also have another problem- for some reason It doesn't recognize nor let me click on any of the top row items on the grid view-only the ones below it, does anyone know why?
this is my XAML :
<Page
x:Class="My_Little_Animal.ShowUsers"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:My_Little_Animal"
xmlns:data="using:My_Little_Animal"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/Assets/changeUserDetailesBackground.jpg"></ImageBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="8*" />
<RowDefinition Height="147*"/>
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<GridView Name="grid1" ItemClick="grid1_ItemClick" IsItemClickEnabled="True" Margin="-70,151,692,50" Grid.RowSpan="2" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<GridView.ItemTemplate>
<DataTemplate x:DataType="data:User">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<StackPanel Margin="100,20,0,0">
<TextBlock Name="t1" FontSize="20" GotFocus="t1_GotFocus" Text="{x:Bind UserId}"/>
<TextBlock Name="t2" FontSize="20" GotFocus="t2_GotFocus" Text="{x:Bind Password}"/>
<TextBlock Name="t3" FontSize="20" GotFocus="t3_GotFocus" Text="{x:Bind UserName}"/>
<TextBlock Name="t4" FontSize="20" GotFocus="t4_GotFocus" Text="{x:Bind Email}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
<Canvas>
<Image Name="loginTitle" Source="/Assets/ShowUsersTitle.png" RenderTransformOrigin="0.5,0.5" Grid.RowSpan="2" Canvas.Left="-325" Canvas.Top="-120" Height="462" Width="1875"/>
<TextBlock Grid.Row="2" Name="ResultTextBlock" FontSize="24" Foreground="Red" FontWeight="Bold" Height="169" Margin="0,0,0,-69"/>
<Image Name="editTheUserName" Width="100" Height="35" Visibility="Visible" Source="/Assets/editIcon.png" RenderTransformOrigin="0.5,0.5" Grid.Row="1" Canvas.Left="852" Canvas.Top="226" />
<Image Name="CancelTheUserNamE" Width="100" Height="35" Visibility="Visible" Source="/Assets/xIcon.png" RenderTransformOrigin="0.485,0.529" Grid.Row="1" Canvas.Left="848" Canvas.Top="224" />
<TextBlock Visibility="Visible" Name="theUserItself" FontFamily="Comic Sans MS" FontWeight="ExtraBold" FontStyle="Italic" FontSize="25" Text="your user name " RenderTransformOrigin="0.496,1.165" Foreground="#FF283D6C" Grid.Row="1" Canvas.Left="1103" Canvas.Top="219" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch"/>
<TextBlock Name="userName" FontFamily="Comic Sans MS" FontWeight="ExtraBold" FontStyle="Italic" FontSize="25" Text="User Name : " RenderTransformOrigin="0.496,1.165" TextDecorations="Underline" Grid.Row="1" Canvas.Left="922" Canvas.Top="224"/>
<TextBox Visibility="Visible" Width="200" Name="UserNameText" MaxLength="50" FontFamily="Comic Sans MS" FontStyle="Italic" FontSize="15" BorderThickness="3" BorderBrush="#FF23677D" Grid.Row="1" Canvas.Left="1099" Canvas.Top="223" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch"/>
<Button Visibility="Visible" Name="changeuserName" Height="49" Width="140" FontSize="20" Content="change" FontWeight="ExtraBold" BorderBrush="White" Foreground="White" BorderThickness="2" Background="#FF191A5C" HorizontalAlignment="Center" VerticalAlignment="Top" RenderTransformOrigin="0.45,0.536" Grid.Row="1" Canvas.Left="1305" Canvas.Top="210" Margin="0,0,0,0"/>
<Image Name="editTheEmail" Canvas.Top="286" Canvas.Left="850" Width="100" Height="35" Visibility="Visible" Source="/Assets/editIcon.png" RenderTransformOrigin="0.49,0.557" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Image Name="CancelTheEmail" Width="100" Height="35" Visibility="Visible" Source="/Assets/xIcon.png" RenderTransformOrigin="0.485,0.529" Grid.Row="1" Canvas.Left="847" Canvas.Top="284" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<TextBlock Visibility="Visible" Name="theEmailItself" FontFamily="Comic Sans MS" FontWeight="ExtraBold" FontStyle="Italic" FontSize="25" Text="your email " RenderTransformOrigin="0.496,1.165" Foreground="#FF283D6C" Grid.Row="1" Canvas.Left="1105" Canvas.Top="276"/>
<TextBlock Name="Email" FontFamily="Comic Sans MS" FontWeight="ExtraBold" FontStyle="Italic" FontSize="25" Text="Email : " RenderTransformOrigin="0.496,1.165" TextDecorations="Underline" Grid.Row="1" Canvas.Left="921" Canvas.Top="283" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<TextBox Visibility="Visible" Width="200" Name="EmailText" MaxLength="50" FontFamily="Comic Sans MS" FontStyle="Italic" FontSize="15" BorderThickness="3" BorderBrush="#FF23677D" Grid.Row="1" Canvas.Left="1093" Canvas.Top="284" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch"/>
<Button Visibility="Visible" Name="changeEmail" Height="49" Width="140" FontSize="20" Content="change" FontWeight="ExtraBold" BorderBrush="White" Foreground="White" BorderThickness="2" Background="#FF191A5C" HorizontalAlignment="Center" VerticalAlignment="Top" RenderTransformOrigin="0.45,0.536" Grid.Row="1" Canvas.Left="1302" Canvas.Top="274" Margin="0,0,0,0"/>
<Image Name="theReturn" Height="100" Width="100" Tapped="theReturn_Tapped_1" Source="/Assets/theReturnIcon.png" RenderTransformOrigin="0.493,0.496" Grid.RowSpan="2" Canvas.Left="65" Canvas.Top="27" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Canvas>
</Grid>
The c# code :
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Xml;
using System.Data;
using Windows.UI.Popups;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace My_Little_Animal
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ShowUsers : Page
{
regitration.regitrationSoapClient cal;
public ShowUsers()
{
this.InitializeComponent();
cal = new regitration.regitrationSoapClient();
getData();
}
public async void getData()
{
regitration.getUserTableResponseGetUserTableResult r = await cal.getUserTableAsync();
List<User> theUserList = new List<User>();
User u = null;
XmlReader xr = r.Any1.CreateReader();
XmlDocument document = new XmlDocument();
document.Load(xr);
XmlNodeList theXmlList = document.GetElementsByTagName("Table");
foreach (XmlElement item in theXmlList)
{
u = new User();
foreach (XmlNode node in item.ChildNodes)
{
switch (node.Name)
{
case "userId": u.UserId = int.Parse(node.InnerText); break;
case "password": u.Password = node.InnerText; break;
case "userName": u.UserName = node.InnerText; break;
case "email": u.Email = node.InnerText; break;
}
}
theUserList.Add(u);
}
grid1.ItemsSource = theUserList;
}
private async void grid1_ItemClick(object sender, ItemClickEventArgs e)
{
var dialog = new MessageDialog("The item that was clicked is : ");
await dialog.ShowAsync();
}
private void t1_GotFocus(object sender, RoutedEventArgs e)
{
}
private void t2_GotFocus(object sender, RoutedEventArgs e)
{
}
private void t3_GotFocus(object sender, RoutedEventArgs e)
{
}
private void t4_GotFocus(object sender, RoutedEventArgs e)
{
}
private void theReturn_Tapped_1(object sender, TappedRoutedEventArgs e)
{
this.Frame.Navigate(typeof(Administrator));
}
}
}
I will be so thankful for any help, it's really important for me!
but I don't know how to get that specific clicked user's details, for me to present them on the side.
There are many ways to get the item in item click event. if you have used MVVM pattern, the recommend way is binding command. For more you could refer this case.
In general, you could subscribe ItemClick event and get ClickedItem from event ItemClickEventArgs
Example
private void VideoGridView_ItemClick(object sender, ItemClickEventArgs e)
{
var vedio = e.ClickedItem as VideoItem;
var item = new MediaPlaybackItem(MediaSource.CreateFromUri(new Uri(vedio.videoUri)));
mediaPlayerElement.Source = item;
}
I also have another problem- for some reason It doesn't recognize nor let me click on any of the top row items on the grid view-only the ones below it, does anyone know why?
I could not reproduce this issue, please check if there is some element cover the top row up cause the grid view could not be clicked.

C# XAML - Getting the XAML Content property (contentControl.Content)

So I have my AML keypad as such :
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Name="btnTotal" Width="280" Height="60" Grid.ColumnSpan="3" Grid.Row="0" Margin="10,10,10,10" Background="#302F37" Foreground="AntiqueWhite" FontSize="35"></TextBox>
<Button x:Name="btnZzero" Content="0" Width="80" Height="60" Grid.Column="0" Grid.Row="4" Margin="5,5,5,5" Background="#302F37" Foreground="White" Focusable="False" Click="btnZzero_Click"></Button>
<Button x:Name="btnOk" Content="OK" Width="80" Height="60" Grid.Column="1" Grid.Row="4" Margin="5,5,5,5" Click="btnOk_Click" Background="#FF8FC377" Focusable="False"></Button>
<Button x:Name="btnCancel" Content="Cancel" Width="80" Height="60" Grid.Column="2" Grid.Row="4" Margin="5,5,5,5" Click="cancel_Click" BorderBrush="Black" Background="#FFD64D4D" Focusable="False"></Button>
<Button x:Name="btnOne" Content="1" Width="80" Height="60" Grid.Column="0" Grid.Row="3" Margin="14,6,0,6" Focusable="False" Background="#302F37" Foreground="White" HorizontalAlignment="Left" Click="btnOne_Click"></Button>
<Button x:Name="btnTwo" Content="2" Width="80" Height="60" Grid.Column="1" Grid.Row="3" Margin="5,5,5,5" Focusable="False" Background="#302F37" Foreground="White" Click="btnTwo_Click"/>
<Button x:Name="btnThree" Content="3" Width="80" Height="60" Grid.Column="2" Grid.Row="3" Margin="5,5,5,5" Focusable="False" Background="#302F37" Foreground="White" Click="btnThree_Click"/>
<Button x:Name="btnFour" Content="4" Width="80" Height="60" Grid.Column="0" Grid.Row="2" Margin="5,5,5,5" Focusable="False" Background="#302F37" Foreground="White" Click="btnFour_Click"></Button>
<Button x:Name="btnFive" Content="5" Width="80" Height="60" Grid.Column="1" Grid.Row="2" Margin="5,5,5,5" Focusable="False" Background="#302F37" Foreground="White" Click="btnFive_Click"></Button>
<Button x:Name="btnSix" Content="6" Width="80" Height="60" Grid.Column="2" Grid.Row="2" Margin="5,5,5,5" Focusable="False" Background="#302F37" Foreground="White" Click="btnSix_Click"></Button>
<Button x:Name="btnSeven" Content="7" Width="80" Height="60" Grid.Column="0" Grid.Row="1" Margin="12,5,9,6" Focusable="False" Background="#302F37" Foreground="White" Click="btnSeven_Click"></Button>
<Button x:Name="btnEight" Content="8" Width="80" Height="60" Grid.Column="1" Grid.Row="1" Margin="5,5,5,5" Focusable="False" Background="#302F37" Foreground="White" Click="btnEight_Click"></Button>
<Button x:Name="btnNine" Content="9" Width="80" Height="60" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5" Focusable="False" Background="#302F37" Foreground="White" Click="btnNine_Click"></Button>
Now I want to write a small helper method to run when each button is clicked but I cannot work out how to use the Content from the XAML.
for example this works for button 1 :
private void btnOne_Click(object sender, RoutedEventArgs e)
{
addButtonNumberToResult();
}
And the helper method uses btnOne.Content but how do I get it to use the Content from any button being pressed? So I can just add the helper methosto each button?
private void addButtonNumberToResult() //helper method
{
if (btnClicked == true)
{
btnTotal.Text = "";
btnClicked = false;
}
QuantityResult = QuantityResult += btnOne.Content;
btnTotal.Text = QuantityResult;
}
You can use the sender variable to determine the button clicked:
private void btn_Click(object sender, RoutedEventArgs e)
{
addButtonNumberToResult((Button)sender);
}
add btn_Click to the Click event of each button (and replace the ones you have already)
private void addButtonNumberToResult(Button btn) //helper method
{
if (btnClicked == true)
{
btnTotal.Text = "";
btnClicked = false;
}
QuantityResult = QuantityResult += btn.Content;
btnTotal.Text = QuantityResult;
}

merged cells won't remove borders between them

I wrote function for droping list items:
private void grid1_Drop(object sender, RoutedEventArgs e)
{
TextBlock textBlock = e.Source as TextBlock;
Console.WriteLine("drop item into grid column:{0} row:{1}",
Grid.GetColumn(textBlock), Grid.GetRow(textBlock));
DataObject item = (((DragEventArgs)e).Data) as DataObject;
ListBoxItem listItem = item.GetData(typeof(ListBoxItem)) as ListBoxItem;
Window1 second = new Window1();
second.ShowDialog();
//textBlock.Height = textBlock.Height*second.getBrCasova();
Grid.SetRowSpan(textBlock, second.getBrCasova());
textBlock.Background = Brushes.Gray;
string pom = "";
if(second.getBrCasova() == 1)
textBlock.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
else
for (int i = 0; i < second.getBrCasova();i++ )
pom += "\n";
textBlock.Text = pom + listItem.Content.ToString() + "\n" + second.getUcionica();
textBlock.TextAlignment = System.Windows.TextAlignment.Center;
textBlock.Margin = new Thickness(0,0,2,2.5);
}
the problem is, if I get Grid.SetRowSpan(textBlock, second.getBrCasova()), second.getBrCasova>2, borders between cells wont be deleted.
This part of xaml show how I make table of textblocks:
<Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<TextBlock Grid.Row="1" Grid.Column="1" Name="TextBlock11" AllowDrop="True" PreviewMouseLeftButtonDown="TextBlock11_PreviewMouseLeftButtonDown"></TextBlock>
<!--<Rectangle Grid.Column="2"
Grid.Row="1"
Stroke="Black"
Fill="Transparent" />-->
<TextBlock Grid.Row="1" Grid.Column="2" AllowDrop="True"></TextBlock>
<!--<Rectangle Grid.Column="3"
Grid.Row="1"
Stroke="Black"
Fill="Transparent" />-->
<TextBlock Grid.Row="1" Grid.Column="3" AllowDrop="True"></TextBlock>
<!--<Rectangle Grid.Column="4"
Grid.Row="1"
Stroke="Black"
Fill="Transparent" />-->
<TextBlock Grid.Row="1" Grid.Column="4" AllowDrop="True"></TextBlock>
....
How to remove this borders from function?
Thanks in advance.

Getting the parent of usercontrol inside Dispatcher.BeginInvoke

Am having a Main window in my WPF application inside which am having a tabcontrol.I need to select the tabitem based on the name i pass.Each of the tabitem will contain a user control.But my problem is am not able to get the parent of the usercontrol using Parent property.Its returning null only always.Can anyone help me out.
public void selectingTab()
{
Dispatcher.BeginInvoke((Action)(() =>
{
string name = todisplayChat.GetValue<string>("FromMessenger");
string msg = todisplayChat.GetValue<string>("ChatSent");
NewChatWindow childWindow = this as NewChatWindow;
MainChatWindow parentWindow = VisualTreeHelper.GetParent(childWindow) as MainChatWindow;
//Am getting null as the value of parentWindow after the execution of this line
TabControl tabcontrolHome = parentWindow.tabcontrol_Chatwindow;
TabItem existingTab = tabcontrolHome.Items.OfType<TabItem>().SingleOrDefault(n => n.Name == name);
childWindow = (NewChatWindow)existingTab.Content;
childWindow.richtxtbox_chatwindow.AppendText(Environment.NewLine + name + " : " + msg);
}));
}
MainChatWindow.XAML
<Window x:Class="Ping.MainChatWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="700" Icon="F:\Dhivya\C#\Personal\ChatApplication\CurrentlyWorking-Important\Ping\Ping\images\ping_logo.png" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" WindowStyle="None" Foreground="{x:Null}" BorderBrush="#FF87A4DB" BorderThickness="2">
<Grid>
<Label Content="Ping" Height="30" HorizontalAlignment="Left" Name="lbl_Titlebar" VerticalAlignment="Top" Width="700" Background="#FF87A4DB" FontFamily="Arial" FontSize="17" Foreground="White" />
<Image Height="20" HorizontalAlignment="Left" Margin="635,5,0,0" Name="img_Minimizebutton" Stretch="Fill" VerticalAlignment="Top" Width="20" Source="F:\Dhivya\C#\Personal\ChatApplication\CurrentlyWorking-Important\Ping\Ping\images\minimize_userpage.png" />
<!--<Label Height="25" HorizontalAlignment="Left" Margin="665,5,0,0" VerticalAlignment="Top" Width="20">-->
<Image MouseEnter="close_icon_MouseEnter_1" MouseDown="close_icon_MouseDown_1" Height="20" HorizontalAlignment="Left" Margin="665,5,0,0" Name="close_icon" Stretch="Fill" VerticalAlignment="Top" Width="20" Source="F:\Dhivya\C#\Personal\ChatApplication\CurrentlyWorking-Important\Ping\Ping\images\close_userpage.png" />
<!--</Label>-->
<Label Content="Groups" Height="28" HorizontalAlignment="Left" Margin="12,46,0,0" Name="lbl_Groups" VerticalAlignment="Top" Background="#FF87A4DB" Foreground="White" BorderBrush="{x:Null}" Width="245" FontSize="16" FontFamily="Arial" />
<RichTextBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="175" HorizontalAlignment="Left" Margin="12,73,0,0" Name="richtxtbox_Groups" VerticalAlignment="Top" Width="245" FontFamily="Arial" />
<Label Background="#FF87A4DB" BorderBrush="{x:Null}" Content="Online Buddies" FontFamily="Arial" FontSize="16" Foreground="White" Height="28" HorizontalAlignment="Left" Margin="12,260,0,0" Name="lbl_Onlinebuddies" VerticalAlignment="Top" Width="245" />
<Grid ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="298" HorizontalAlignment="Left" Margin="12,288,0,0" Name="richtxtbox_Onlinebuddies" VerticalAlignment="Top" Width="245"></Grid>
<!--<RichTextBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="298" HorizontalAlignment="Left" Margin="12,288,0,0" Name="richtxtbox_Onlinebuddies" VerticalAlignment="Top" Width="245" FontFamily="Arial" />-->
<TabControl Height="540" HorizontalAlignment="Left" Margin="274,46,0,0" Name="tabcontrol_Chatwindow" VerticalAlignment="Top" Width="410">
<TabItem Header="My Profile" Name="ProfileTab">
</TabItem>
</TabControl>
</Grid>
NewChatWindow.Xaml
<UserControl x:Class="Ping.NewChatWindow"
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="540" d:DesignWidth="410">
<Grid>
<TextBox LostFocus="txt_Userinput_LostFocus_1" Foreground="Gray" GotFocus="txt_Userinput_GotFocus_1" KeyDown="txt_Userinput_KeyDown_1" Height="65" HorizontalAlignment="Left" Margin="13,161,0,0" Name="txt_Userinput" VerticalAlignment="Top" Width="378" FontFamily="Arial" Text="Enter Your Words Here" />
<RichTextBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="246" HorizontalAlignment="Left" Margin="13,253,0,0" Name="richtxtbox_chatwindow" VerticalAlignment="Top" Width="378" FontFamily="Arial" />
<Image Height="93" HorizontalAlignment="Left" Margin="36,36,0,0" Name="image2" Stretch="Fill" VerticalAlignment="Top" Width="65" Source="F:\Dhivya\C#\Personal\ChatApplication\CurrentlyWorking-Important\Ping\Ping\images\user_logo.png"/>
<Label Content="Label" Height="37" HorizontalAlignment="Left" Margin="124,24,0,0" Name="lbl_Username" VerticalAlignment="Top" Width="278" FontSize="24" />
<Label Content="Label" Height="28" HorizontalAlignment="Left" Margin="125,52,0,0" Name="lbl_Statusmsg" VerticalAlignment="Top" Width="284" />
<Image Height="40" Width="30" HorizontalAlignment="Left" Margin="131,89,0,0" Name="img_Profileview" Stretch="Fill" VerticalAlignment="Top" Source="F:\Dhivya\C#\Personal\ChatApplication\CurrentlyWorking-Important\Ping\Ping\images\user_logo.png" ToolTip="Add contact"/>
<Image MouseDown="img_Sendingfile_MouseDown_1" Height="40" Width="40" HorizontalAlignment="Left" Margin="191,89,0,0" Name="img_Sendingfile" Stretch="Fill" VerticalAlignment="Top" Source="F:\Dhivya\C#\Personal\ChatApplication\CurrentlyWorking-Important\Ping\Ping\images\sendingfile_icon.png" ToolTip="Fileupload"/>
<Image Height="40" Width="40" HorizontalAlignment="Left" Margin="261,89,0,0" Name="img_Videochat" Stretch="Fill" VerticalAlignment="Top" Source="F:\Dhivya\C#\Personal\ChatApplication\CurrentlyWorking-Important\Ping\Ping\images\videochat_logo.png" ToolTip="Video chat"/>
<Image MouseDown="img_Myfolder_MouseDown_1" Height="40" Width="40" Name="img_Myfolder" Stretch="Fill" Source="F:\Dhivya\C#\Personal\ChatApplication\CurrentlyWorking-Important\Ping\Ping\images\myfolder_logo.png" Margin="329,89,41,411" ToolTip="View chat history" />
<Border BorderBrush="#FF87A4DB" BorderThickness="1" HorizontalAlignment="Left" Margin="10,18,0,367" Name="border_Userdetails" Width="378" CornerRadius="2" />
</Grid>
Am having a set of labels for the online users.So when i double click any label i ll do the following
private void Label_MouseDoubleClick_1(object sender, MouseButtonEventArgs e)
{
Label selectedLabel = (Label)sender;
TabItem existingTab = tabcontrol_Chatwindow.Items.OfType<TabItem>().SingleOrDefault(n => n.Name == selectedLabel.Content);
if (tabcontrol_Chatwindow.Items.Contains(existingTab))
{
tabcontrol_Chatwindow.SelectedItem = existingTab;
}
else
{
TabItem newTab = new TabItem();
newTab.Name = selectedLabel.Content.ToString();
TabHeader header = new TabHeader();
header.userName.Content = selectedLabel.Content;
newTab.Header = header;
//newTab.Header = selectedLabel.Content;
newTab.Content = new NewChatWindow();
tabcontrol_Chatwindow.Items.Add(newTab);
tabcontrol_Chatwindow.SelectedItem = newTab;
}
}
Try using the below code, in which you can find the Window hosting your Usercontrol using Window parentWindow = Window.GetWindow(this);
Dispatcher.BeginInvoke((Action)(() =>
{
string name = todisplayChat.GetValue<string>("FromMessenger");
string msg = todisplayChat.GetValue<string>("ChatSent");
NewChatWindow childWindow = this as NewChatWindow;
MainChatWindow parentWindow = Window.GetWindow(this) as MainChatWindow;
TabControl tabcontrolHome = parentWindow.tabcontrol_Chatwindow;
TabItem existingTab = tabcontrolHome.Items.OfType<TabItem>().SingleOrDefault(n => n.Name == name);
childWindow = (NewChatWindow)existingTab.Content;
childWindow.richtxtbox_chatwindow.AppendText(Environment.NewLine + name + " : " + msg);
}));

Categories

Resources