TextEditorOption throw “Object reference not set to an instance of an object” when VM is destructed
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu với WPF TabControl.ContentTemplate được hiển thị và liên kết Options trên TextEditorEx. Tái hiện việc xóa một view model khỏi DocList trong khi Options đang được liên kết, sau đó theo dõi sự kiện OptionsChanged gây ra ngoại lệ tham chiếu null. Hoàn tất khi việc đóng một tab không còn gây ra ngoại lệ trong quá trình xóa view model.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I'm working on a notepadplus-like editor with avalonEdit.
I made a control class based on avalonedit and put it in a tab control template like this:
<TabControl Grid.Row="3" ItemsSource="{Binding DocList}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" >
<TabControl.ItemTemplate>
<DataTemplate>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<Grid>
<Grid.Resources>
<avalonEdit:TextEditorOptions x:Key="TextEditOptions" />
</Grid.Resources>
<controls:TextEditorEx x:Name="avEditor"
Background="White"
Foreground="Black"
LineNumbersForeground="Black"
ShowLineNumbers="{Binding ShowLineNumbers, UpdateSourceTrigger=PropertyChanged}"
IsModified="{Binding Path=IsDirty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SyntaxHighlighting="{Binding HighlightingDefinition, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Document="{Binding Document, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Column="{Binding SynchronizedColumn,Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
Line="{Binding SynchronizedLine,Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
FontSize="{Binding SynchronizedFontSize, UpdateSourceTrigger=PropertyChanged}"
FontFamily="{Binding SynchronizedFontFamily, UpdateSourceTrigger=PropertyChanged}"
Options="{Binding TextEditorOptionsSetting, FallbackValue={StaticResource TextEditOptions}}"
>
</controls:TextEditorEx>
</Grid>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
and DocList is a list of viewmodel for controls:TextEditorEx, when click close btn of tab , certain vm will be removed from DocList.
it works fine until i bind Options to VM,when VM is removed from DocList, it triggers OptionsChanged Event and throws “Object reference not set to an instance of an object”.
I'm new to MVVM and WPF so how can I fix this problem? It seems to me the View Model should be destruct AFTER control does.
- Ngôn ngữ chính
- C#
- Star
- 2.1k
- Fork
- 496
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của icsharpcode/AvalonEdit
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
icsharpcode/AvalonEdit#454 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
icsharpcode/AvalonEdit#449 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
icsharpcode/AvalonEdit#446 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 28/100
icsharpcode/AvalonEdit#445 · 1 bình luận ·
-
Context menu ApplicationCommands.Cut still enabled when IsReadOnly = trueCó thể đã có người làm @JyslaFancy đã nhận 162 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
icsharpcode/AvalonEdit#444 ·
Tất cả issue của icsharpcode/AvalonEdit
Issue tương tự
-
type:task ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
elsa-workflows/elsa-foundation#5253 ·
Maintainer thường phản hồi trong vòng 1 ngày