阅读背景:

即使模型已更新,也无法更新视图

来源:互联网 

This is my XAML

这是我的XAML

<Window x:Class="NoteBox.MainWindow"
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:NoteBox"
    Title="NoteBox">
<Window.Resources>
    <local:NoteOctaveConverter x:Key="NoteOctaveConverter"/>
    <local:DottedNoteConverter x:Key="DottedNoteConverter"/>
    <local:NoteEnumerationConverter x:Key="NoteEnumerationConverter"/>
    <local:NoteAccidentalConverter x:Key="NoteAccidentalConverter"/>
</Window.Resources>
<Window.InputBindings>
    <KeyBinding Key="OemPeriod" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="Blank"/>
    <KeyBinding Key="D0" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="Rest"/>
    <KeyBinding Key="D1" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="N1"/>
    <KeyBinding Key="D2" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="N2"/>
    <KeyBinding Key="D3" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="N3"/>
    <KeyBinding Key="D4" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="N4"/>
    <KeyBinding Key="D5" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="N5"/>
    <KeyBinding Key="D6" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="N6"/>
    <KeyBinding Key="D7" Command="{Binding KeyboardHotkeyCommand}" CommandParameter="N7"/>
</Window.InputBindings>

<Grid x:Name="grid" Background="GreenYellow">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="20"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="20"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="20"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="20"/>
    </Grid.RowDefinitions>

    <TextBlock Grid.Column="0" Grid.Row="1"
               Text="{Binding Path=MusicalNotation.Accidental, Converter={StaticResource NoteAccidentalConverter}, Mode=OneWay}" 
               FontSize="15" FontFamily="CourierNew" 
               HorizontalAlignment="Center" VerticalAlignment="Center"/>
    <TextBlock Grid.Column="1" Grid.Row="1" 
               Text="{Binding Path=MusicalNotation.Note, Converter={StaticResource NoteEnumerationConverter}, Mode=OneWay}" 
               FontSize="15" FontFamily="CourierNew" 
               HorizontalAlignment="Center" VerticalAlignment="Center"/>
    <ListBox Grid.Column="1" Grid.Row="0"
             BorderBrush="Transparent" Background="Transparent"
             ItemsSource="{Binding Path=MusicalNotation.Octave, Converter={StaticResource NoteOctaveConverter}, ConverterParameter=TOP, Mode=OneWay}"
             HorizontalAlignment="Center" VerticalAlignment="Center">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel IsItemsHost="True"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
    <ListBox Grid.Column="1" Grid.Row="2"
             BorderBrush="Transparent" Background="Transparent"
             ItemsSource="{Binding Path=MusicalNotation.Octave, Converter={StaticResource NoteOctaveConverter}, ConverterParameter=BOT, Mode=OneWay}"
             HorizontalAlignment="Center" VerticalAlignment="Center">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel IsItemsHost="True"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
    <ListBox Grid.Column="2" Grid.Row="1"
             BorderBrush="Transparent" Background="Transparent"
             ItemsSource="{Binding Path=MusicalNotation.Dot, Converter={StaticResource DottedNoteConverter}, Mode=OneWay}"
             HorizontalAlignment="Center" VerticalAlignment="Center">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel IsItemsHost="True"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
</Grid>
<Window x:Class="N



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: