我已经研究了一段时间,试图找到以下内容的原因,但StackOverflow或Google上的解决方案都无法帮助我.
我有一个自定义UserControl试图引用同一项目中的命名空间:
xmlns:my="clr-namespace:ColorPicker"
Run Code Online (Sandbox Code Playgroud)
但是当我编译时,我收到以下错误:
未定义的CLR命名空间.'clr-namespace'URI是指未包含在程序集中的命名空间'ColorPicker'.
这导致无法在xaml中构建我的项目或引用其他自定义控件,从而产生以下类型的错误:
找不到类型'my:ColorSelector'.验证您是否缺少程序集引用,并且已构建所有引用的程序集.
我试过这些帖子中给出的所有解决方案:
WPF xmlns:'clr-namespace'URI是指未包含在程序集中的命名空间
"clr-namespace"URI指的是未包含在程序集中的命名空间
另外,为了清楚起见,我没有得到关于此项目中其他文件的任何其他错误,因此它似乎不是其他文件无法编译的结果.
更新:为我生成错误的示例项目可以在这里下载:http://www.filefactory.com/file/28fbmhj3f4qj/n/ColorPicker_zip
我们有一个自定义DataGrid控件,可以动态生成由XML结构确定的列.
在创建每个列时,我们给它一个星号单位类型,因为我们要确保在DataGrid中永远不会有任何水平滚动.
DataGridTextColumn column = new DataGridTextColumn();
column.Width = new DataGridLength(entity.DisplaySize, DataGridLengthUnitType.Star);
Run Code Online (Sandbox Code Playgroud)
但是,我们注意到,当渲染DataGrid时,它会以给定列的最小大小呈现,然后在完全呈现DataGrid后,它会调整列的大小以适合DataGrid.这会导致闪烁效应.
有人有任何可能的解决方案吗?也许如何在后台呈现DataGrid,然后在列完成后显示?还是其他任何想法?
我已经创建了一个github存储库,它有一个完美的问题示例.
https://github.com/rjriel/dynamic-route-example
这个回购中代码的重要部分是 app.module.ts
let mainRoutes: Routes = [{
path: "first",
component: FirstComponent
}]
mainRoutes.push({
path: "second",
component: SecondComponent
})
@NgModule({
...
imports: [
RouterModule.forRoot(mainRoutes),
Run Code Online (Sandbox Code Playgroud)
在开发中运行此代码(即.ng serve)时,两个路由都正确导航.但是,在生产中运行此代码(即.ng serve --prod)时second,添加的路由会mainRoutes.push导致以下错误:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL
Segment: 'second'
Error: Cannot match any routes. URL Segment: 'second'
at t.BkNc.t.noMatchError (vendor.0828fd59ec5e6a599e72.bundle.js:1)
at e.selector (vendor.0828fd59ec5e6a599e72.bundle.js:1)
at e.error (vendor.0828fd59ec5e6a599e72.bundle.js:1)
at e.T14+.e._error (vendor.0828fd59ec5e6a599e72.bundle.js:1)
at e.T14+.e.error (vendor.0828fd59ec5e6a599e72.bundle.js:1)
at e.T14+.e._error (vendor.0828fd59ec5e6a599e72.bundle.js:1)
at e.T14+.e.error (vendor.0828fd59ec5e6a599e72.bundle.js:1)
at …Run Code Online (Sandbox Code Playgroud) development-environment production-environment angular2-routing angular
我有一个带有树视图和文本框的应用程序:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="550" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<TreeView Width="500" Height="500" Name="TestTreeView">
</TreeView>
<TextBox Grid.Row="1"></TextBox>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
在应用程序的构造函数中,我生成1000个项目,每个项目有1个子项目并将其添加到TreeView:
public MainWindow()
{
InitializeComponent();
for (int i = 0; i < 1000; i++)
{
TreeViewItem item = new TreeViewItem();
item.Header = "Hey there " + i.ToString();
TreeViewItem subItem = new TreeViewItem();
subItem.Header = "Hi there";
item.Items.Add(subItem);
TestTreeView.Items.Add(item);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的场景中,我选择TreeView的第二项,然后单击进入TextBox以使焦点远离TreeView.然后我用鼠标向下滚动TreeView,将所选项目从视口中移出.然后我扩展另一个项目而不选择它.我的预期结果是我的滚动停留在当前位置,但是它将所选项目滚动到视图中,导致我丢失了我正在扩展的项目.
如果TreeView已经具有焦点,则不会发生这种情况.如果我要选择一个项目,然后向下滚动并展开另一个项目,则不会发生这种跳回所选项目的行为.
这是正常的行为吗?例如,如果我在Visual Studio的解决方案资源管理器中执行这些相同的选择步骤,我就不会遇到这种行为.有没有办法告诉它不要回滚到这样的选定项目?
我知道我可以简单地将RequestBringIntoView的e.Handled设置为true,但是我给出的示例只是对我的问题的一个简单解释.这是我在一个更大的应用程序中使用的TreeView问题的一个例子,我希望在某些条件下将项目带入视图.
我正在代码中创建触发器,我正在尝试将setter的值绑定到后面代码中创建的动态资源,这样我就可以更新资源,并且仍然可以更新setter的值.我就此而已
SolidColorBrush brush = Brushes.Red;
Resources.Add("NewBrush",brush);
Setter setter = new Setter();
setter.Property = Control.BackgroundProperty;
Run Code Online (Sandbox Code Playgroud)
但我不确定如何将setter的值绑定到创建的动态资源.我不能简单地在XAML中创建资源,因为资源需要动态创建.如何将Setter的值绑定到动态资源,因此更改资源将改变setter的值.
更多信息要澄清.这都是在代码后面完成的,因为一切都是动态生成的.触发器,设置器,格式化,控件都是基于XML结构创建的.
我正在为我的应用程序构建一个kill开关,这样一台计算机上一次只能运行一个实例.我通过在正在运行的应用程序的进程和应用程序的新实例的进程之间发布消息来实现此目的:
[DllImport("user32.dll", EntryPoint = "PostMessageA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int PostMessage(int hwnd, int wMsg, int wParam, int lParam);
Run Code Online (Sandbox Code Playgroud)
我不能使用Process.Kill,因为如果另一个用户正在运行该应用程序并且当前用户没有足够的权限我会遇到问题.
在同一用户帐户下运行2个实例时,我没有任何问题.消息正确发送并正确接收.但是,当从一个用户帐户运行一个实例,然后切换用户并运行第二个实例时,我的第一个实例没有收到消息.
这是我订阅窗口消息的逻辑:
var wih = new WindowInteropHelper(this);
var hwndSource = HwndSource.FromHwnd(wih.Handle);
var hwndSourceHook = new HwndSourceHook(HookHandler);
if (hwndSource != null)
hwndSource.AddHook(hwndSourceHook);
Run Code Online (Sandbox Code Playgroud)
这是我的钩子处理程序:
private IntPtr HookHandler(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
handled = false;
switch (msg)
{
case 0x400: // interprocess message received
App.InterprocessManager.BuildString(lParam);
break;
}
return IntPtr.Zero; …Run Code Online (Sandbox Code Playgroud) 目前我有一个带有自定义UserControl的WPF项目.此控件包含一个网格,其中包含多个表单类型元素(复选框,文本框,组合框等).该控件旨在作为一个表单进行查看和操作,但它被放置在拖动画布内,这就是它需要是UserControl而不是窗口的原因.
问题是元素之间的选项卡导航需要限制在此控件中,所以当我按下控件中最后一个元素的"Tab"键时,键盘会聚焦控件中的第一个元素.目前,它不受控制范围内的应用程序中的下一个tabbable元素.
除了手动捕获关键事件之外,还有另一种方法可以将选项卡导航限制为单个WPF UserControl吗?