Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF Helix 3d如何装订&x27;项目';到BillboardTextGroupVisual3D_C#_Wpf_List_Data Binding_Helix 3d Toolkit - Fatal编程技术网

C# WPF Helix 3d如何装订&x27;项目';到BillboardTextGroupVisual3D

C# WPF Helix 3d如何装订&x27;项目';到BillboardTextGroupVisual3D,c#,wpf,list,data-binding,helix-3d-toolkit,C#,Wpf,List,Data Binding,Helix 3d Toolkit,我想将BillboardTextGroupVisual3D中的项目绑定到XAML中,并且我还检查了关于这些项目的DependencyProperty的源代码,如下所示 public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register( "Items", typeof(IList<BillboardTextItem>), typeof(BillboardTextGroupVisua

我想将BillboardTextGroupVisual3D中的项目绑定到XAML中,并且我还检查了关于这些项目的DependencyProperty的源代码,如下所示

public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register(
"Items",
typeof(IList<BillboardTextItem>),
typeof(BillboardTextGroupVisual3D),
new UIPropertyMetadata(null, VisualChanged));
公共静态只读DependencyProperty项属性=DependencyProperty.Register( “项目”, 类型(IList), 类型(BillboardTextGroupVisual3D), 新的UIPropertyMetadata(null,VisualChanged)); 在这里,我跳过了我尝试过的代码片段,但所有这些都失败了。 我不知道如何动态更新列表中的DependencyProperty

在MainWindows.xaml中,我用TextItems3绑定这些项

<h:BillboardTextGroupVisual3D Background="White" BorderBrush="Black" Foreground="Black" BorderThickness="1" FontSize="12" Padding="2" 
                              Offset="20,20" PinBrush="Gray" Items="{Binding TextItems3}" IsEnabled="True"  />

在MainWindows.xaml.cs中,有人告诉我使用ObservableCollection,但仍然失败

public partial class MainWindow : Window, INotifyPropertyChanged 
{

    public event PropertyChangedEventHandler PropertyChanged;

    public IList<BillboardTextItem> textItems3;

    public IList<BillboardTextItem> TextItems3
    {
        get
        {
            return textItems3;
        }
        set
        {
            textItems3 = value;

            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs("TextItems3"));
            }
        }
    }

    DispatcherTimer _timer;
    public MainWindow()
    {
        InitializeComponent();

        this.textItems3 = new ObservableCollection<BillboardTextItem>();
        this.textItems3.Add(new BillboardTextItem { Text = "It's be added in the first executed.", Position = new Point3D(i * 10, 0, 0.5), DepthOffset = 0, WorldDepthOffset = 0.2 });

         _timer = new DispatcherTimer();
        _timer.Interval = TimeSpan.FromMilliseconds(1000);
        //加入callback function
        _timer.Tick += _timer_Tick;

        //開始
        _timer.Start();

        this.DataContext = this;
    }

    int i = 0;
    void _timer_Tick(object sender, EventArgs e)
    {
        this.textItems3.Add(new BillboardTextItem { Text = "I want to add this dynamically.", Position = new Point3D(i*10, 0, 0.5), DepthOffset = 0, WorldDepthOffset = 0.2 });
        TextItems3 = textItems3;
        i++;
    }
}
public分部类主窗口:窗口,INotifyPropertyChanged
{
公共事件属性更改事件处理程序属性更改;
公共IList文本项3;
公共IList文本项3
{
得到
{
返回文本项3;
}
设置
{
textItems3=值;
if(this.PropertyChanged!=null)
{
this.PropertyChanged(这是新的PropertyChangedEventArgs(“TextItems3”);
}
}
}
调度定时器;
公共主窗口()
{
初始化组件();
this.textItems3=新的ObservableCollection();
this.textItems3.Add(new BillboardTextItem{Text=“它将在第一次执行时添加。”,Position=new Point3D(i*10,0,0.5),DepthOffset=0,WorldDepthOffset=0.2});
_计时器=新调度程序();
_timer.Interval=TimeSpan.From毫秒(1000);
//加入回调函数
_timer.Tick+=\u timer\u Tick;
//開始
_timer.Start();
this.DataContext=this;
}
int i=0;
void\u timer\u Tick(对象发送方,事件参数e)
{
this.textItems3.Add(new BillboardTextItem{Text=“我想动态添加它。”,Position=new Point3D(I*10,0,0.5),DepthOffset=0,WorldDepthOffset=0.2});
TextItems3=TextItems3;
i++;
}
}