English 中文(简体)
必须在与依赖性相同的条件下建立依附性
原标题:Must create DependencySource on same Thread as DependencyObject

我用纸张书写申请,下载一些网页,编号为html,并节省一些价值。

class ListOfItems
{    
    public List<SomeObject> ListToBind;
    public void DownloadItems()
    { 
        Task.Factory.StartNew(() => 
        {
            ...
            ...
            if (OnDownloadCompleted != null)
                OnDownloadCompleted(this, EventArgs.Empty);
        }
    }
}

class SomeObject
{
    public string NameOfItem;
    public MyClass Properties;
}

class MyClass
{
    public int Percentage;
    public SolidColorBrush Color;
}

这是使用目标模型Im。 它简化了版本,我不想让你重新组织,因此我这样写了。 http://www.c.un.org。 班级是所有工作都采用的方法(在编码可读性时使用的某些其他方法)——下载源、舱面和填表,附有数据,f.e。

[0] => NameOfItem = "FirstOne", Properties = {99, #FF00FF00}
[1] => NameOfItem = "SecondOne", Properties = {50, #FFFF0000}
etc.

如您所知,当这一方法完成其工作时,便提出OnDownloadCompleted。 在主线上,正遵循法典

void listOfItems_OnDownloadCompleted(object sender, EventArgs args)
{
    dataGrid.Dispatcher.Invoke(new Action(() => { 
                dataGrid.ItemsSource = ListOfItemsInstance.ListToBind;
            }));
}

DataGrid on the MainWindow.xaml is filled with values, because of following xaml code snippet.

<DataGrid Name="dataGrid" AutoGenerateColumns="False">
    <DataGrid.Columns>
         <DataGridTextColumn Header="Tag" Binding="{Binding Name}"/>
         <DataGridTextColumn Header="Color" Binding="{Binding MyClass.Percentage}">
             <!--<DataGridTextColumn.CellStyle>
                 <Style TargetType="DataGridCell">
                     <Setter Property="Background" Value="{Binding MyClass.Color}" />
                 </Style>
             </DataGridTextColumn.CellStyle>-->
         </DataGridTextColumn>
    </DataGrid.Columns>
</DataGrid>

它只是罚款。 但存在这一问题。 听说Xaml snippet,你将获得<代码>。 必须在与属地物体相同的基础上产生依附系数。

最后,我的问题是,如何避免这一错误?

http://www.un.org。

It should look like this in the end. This picture is taken from MS Excel and coloured in Adobe Photoshop.

“example”/

最佳回答
问题回答

我认为,标准方法是在将数据标本通过至另一个读物之前,从<条码>中提取。 一旦该物体被冻结,你就能够再改变该物体,因此不存在穿透的危险。

另一种选择是,将数据标的变成一个简单的C#物体(不是来自<条码>的DisplerObject)并执行<条码>的指定格式<>。

Its not enough to set your dataGrid.ItemsSource on the main thread. You must create each item on the main-thread. Something like:

List<SomeObject> l = new List<SomeObject>();
foreach(var item in ListOfItemsInstance.ListToBind)
{
    l.Add(new SomeObject(){NameOfItem = item.NameOfItem, Properties = item.Properties });
}

dataGrid.ItemsSource = l;




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签