I have a custom control with bindings like below
<DataTemplate DataType="{x:Type vm:EditorTabViewModel}">
<me:MarkdownEditor
Options="{Binding Path=Options, RelativeSource={RelativeSource AncestorType=Window}}" />
</DataTemplate>
I find that binding (Window1.Options
) is being set (after stepping through code in debug mode), the markdown editor options (supposed to set Fonts, Colors etc) does not get set, or at least the UI does not update. I want to bug whats happening with in the MarkdownEditor.xaml.cs
but thats another (referenced) project. How can I verify that the MarkdownEditor.Options
is being set at least?
I have actually tested that the MarkdownEditor
side is working by the below
<Window ...>
<Grid>
<Button Content="Options" Click="Button_Click" Grid.Row="0" />
<me:MarkdownEditor Options="{Binding Options, RelativeSource={RelativeSource AncestorType=Window}}" Grid.Row="1" />
</Grid>
</Window>
So the difference is the latter is a MarkdownEditor
just in a Grid
in a Window
. The one failing is a MarkdownEditor
within a TabControl
bound to a ObservableCollection<TabViewModel>
Visual Studio Solution Replicating The Problem
I am not really good at explaining things, so a simple project I made up minus all the unnecessary noise uploaded to media fire so you can take a look at whats wrong
The video showing the problem on Screenr
With just a simple usage, editor in a window/grid.
the binding works ok
Then when used in conjunction with TabControl
bound to ObservableCollection<EditorTabViewModel>
, the binding works as shown in the 2 TextBox
es updating its values. but the editor does not update
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…