我正在使用RibbonWindow
,在我使用的第一部分中
ribbonBar按钮和其他控件,在第二部分我用DockPanel
显示/加载其他控件
我有两个userControl,一个是使用TextBox
显示详细信息
和DropDown
控件和另一个userControl将显示所有
DataGrid中的现有数据..
这两个控件必须放在DockPanel的基础上
条件,在RibbonWindow
...
现在,我想要的是当我点击任何一个网格行时,我 需要将选定的GridRow数据填充到DisplayUserControl中 (userControl1)和userControl必须加载(替换第二个 userControl)到DockPanel ...
我所做的是......
首先我将UserControl2
加载到Dockpanel
RibbonWindow
并填写网格数据
我已经使用ClickEvent获取了Grid Row的值
(GridList_MouseDoubleClick()
)
并在该方法中我调用One DelegateEvent来调用Method 在MainRibbonWindow声明......
该方法应该显示DockPanel
并加载另一个userControl。代码如下。
以下方法在MainRibbonWindow ...
public void fnDisplayEmployeeDetails(string str,DockPanel dockPannel)
{
// dockPannel is to be cleared...
this.Dispatcher.BeginInvoke((Action)delegate { dockPannel.Children.Clear(); }, null); //To Clear the Dock Panel
CtlAddEmployee frm2 = new CtlAddEmployee(str); //userControl1 and here str is Id of the Row...
dockPannel.Children.Add(frm2);
}
这里完成了所有工作,但DockPanel
仍然存在
仅限第二个userControl(仅显示网格)。 dockpanel没有
替换为firstUserControl
如果我试图在另一个窗口中显示相同的值 Dockpanel,它显示很好。我不知道为什么这么奇怪 行为正在发生......
public void fnDisplayEmployeeDetails(string str,DockPanel docPannel)
{
this.Dispatcher.BeginInvoke((Action)delegate { docPannel.Children.Clear(); }, null); //To Clear the Dock Panel
CtlAddEmployee frm2 = new CtlAddEmployee(str);
MainWindow mnWindow = new MainWindow(); //another window Form...
mnWindow.MainWindowDock.Children.Add(frm2);
mnWindow.ShowDialog(); //here it is showing well....
}
如何在另一个用户控件中显示网格值的详细信息,并且必须在同一个Dockpanel中填充该usercontrol ....
答案 0 :(得分:0)
您是否尝试过不委托添加子控件?我发现当您从不同的线程访问UI组件时,可能会发生这些行为。在不同窗口(第二个测试工作)的情况下,由于新窗口是在新线程中创建的,因此交互工作正常....