[英]C# SilverLight User Control - Custom Panel not presented on the Form (XAML.CS file)
I made very simple Silver Light User Control (Custom Panel) with one text box (named "field") and I am trying to present custom panel in the form but although class is triggered and I can see debug information ("Control Init 2" and "Control Load 2" are in Debug output) but panel and textbox are not presented. 我用一个文本框(名为“ field”)制作了非常简单的Silver Light用户控件(“自定义面板”),我试图以表单的形式显示自定义面板,但是尽管触发了类并且我可以看到调试信息(“ Control Init 2”和“控制负载2”在“调试”输出中),但未显示面板和文本框。
XAML.CS file is the following: XAML.CS文件如下:
namespace CustomPanel2
{
public partial class SilverlightControl1 : W6CustomPanelControlBase
{
public SilverlightControl1()
{
InitializeComponent();
Debug.WriteLine("Control Init 2");
}
private void LoadTest(object sender, RoutedEventArgs e)
{
field.Text = "aaa";
Debug.WriteLine("Control Load 2");
}
}
}
XAML file has the following: Loaded="LoadTest"
XAML文件具有以下内容:
Loaded="LoadTest"
XAML definition is the following: XAML定义如下:
<BaseClass:W6CustomPanelControlBase
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:BaseClass="clr-namespace:W6.Web.FormEngine.PropertyPanels;assembly=W6.Web.FormEngine"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="CustomPanel2.SilverlightControl1"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" Loaded="LoadTest">
<Grid x:Name="LayoutRoot" Background="White">
<TextBox x:Name="field" HorizontalAlignment="Left" Height="23" Margin="40,135,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" TextChanged="TextBox_TextChanged" Background="#FF30E6D5" FontWeight="Bold"/>
</Grid>
</BaseClass:W6CustomPanelControlBase>
From the XAML you presented (as well as from the .cs code) I can see you're not using a typical UserControl
. 从您提供的XAML(以及.cs代码),我可以看到您没有使用典型的
UserControl
。 Instead you are using something called a W6CustomPanelControlBase
from W6.Web.FormEngine.PropertyPanels
. 相反,您使用的是
W6CustomPanelControlBase
的W6.Web.FormEngine.PropertyPanels
。
What that is and how that works? 那是什么以及它如何工作? I have no idea.
我不知道。 Without knowing how it works it'll be difficult to tell you what you did wrong.
如果不知道它是如何工作的,将很难告诉您您做错了什么。
Also - typically a UserControl
is displayed as part of another XAML - a Page
, another UserControl
or a Frame
. 另外-通常,一个
UserControl
显示为另一个XAML的一部分-一个Page
,另一个UserControl
或一个Frame
。 The XAML code you posted is only the the user control itself, but not how it's shown - in other words - the problem might not lie with the user control itself but with how it's shown. 您发布的XAML代码只是用户控件本身,而不是用户控件的显示方式-换句话说,问题可能不在于用户控件本身,而在于用户控件的显示方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.