The question is most likely very naive, but I just can not find the appropriate answer. There is a main program written in C #. From it you need to create a new window.

Inserted XML element. Added it manually.

<UserControl x:Class="Nevatec_Demo.Ship.UserControl" xmlns="" xmlns:x="" xmlns:mc="" xmlns:d="" xmlns:local="clr-namespace:Nevatec_Demo" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="450"> <Canvas> <Path Name="_ShipProfile" Canvas.Top="15" Canvas.Left="-16" Fill=" Red" Stroke="Gainsboro" StrokeThickness="2" Data="M 90, 30 L 90, 90 ... Z" DataContext="{Binding}"></Path> <Path Name="_Arrow" Canvas.Top="0" Canvas.Left="0" StrokeThickness="5" Stroke="Green" Data="M 200,30 L120,30 ..." Height="43" Width="450"></Path> </Canvas> </UserControl> 

The question is how to connect it to the main program?

Dop .: When going to the code, ship.xaml.cs is created:

 // ... namespace Nevatec_Demo { public partial class Ship : Form1 { public Ship() { InitializeComponent(); } } } 

This InitilizeComponent is "unavailable due to its level of protection." I would like this window to open as a child and control elements _ShipProfile and _Arrow was from the main code.

  • XML fix on xaml in one place. :) The main program is what is (WPF or WinForms)? Working through Visual Studio? VS has a small bug when working with xaml on WinForms. - Olter
  • No, no, you do something wrong. The easiest way is to simply redo your application on WPF. Or if you really do not want, make a separate WPF-assembly, add it as a reference, and insert it through the element host . - VladD

1 answer 1

In the system everything is done logically. You are a little confused, but in fact it is not clear what you want to get. You open your control, but where is it located? if you have a WPF form, then everything is simple, if there is a WindowsForms form, then there is also a WPF host. But the control itself just does not display. And access can be obtained, only from the question your program structure is not clear.

  • Thanks semenvx27! In fact, I really need to reformulate the question. The task is as follows: There is a main program that I would like to do in the main window. Several windows should be called from the main window, which should show text data and some graphics that change as a result of changes in data from the main stream. XAML is interesting because I saw the possibility of simply changing shapes there. Maybe there is another way to make everything work correctly. I work from VS2010. A Windows Form is created. Question - mikle-d
  • The question is how to do? - mikle-d