1
VB.NETプロジェクトに統合するためにMVVM Lightを使用しています。最小限の例をセットアップしましたが、うまくいかないでしょう。バインディングはのviewmodelに一方向のみに行くようだが、何の通知はビューに到着しません:モデルはまっすぐ進むMVVM LightとVB.NETによるデータバインディング
Namespace mvvmlight2.ViewModel
Public Class MainViewModel
Inherits ViewModelBase
Public Property Size As Integer
....
ロケータ
Namespace mvvmlight2.ViewModel
Public Class ViewModelLocator
Public Sub New()
ServiceLocator.SetLocatorProvider(Function() SimpleIoc.[Default])
SimpleIoc.Default.Register(Of MainViewModel)()
End Sub
Public ReadOnly Property Main As MainViewModel
Get
Return ServiceLocator.Current.GetInstance(Of MainViewModel)
End Get
End Property
End Class
End Namespace
ビュー行く
<Application x:Class="Application"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:mvvmlight2"
StartupUri="MainWindow.xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d1p1:Ignorable="d"
xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Application.Resources>
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" xmlns:vm="clr-namespace:mvvmlight2.mvvmlight2.ViewModel" />
</Application.Resources>
</Application>
DataContext="{Binding Path=Main, Source={StaticResource Locator}}"
...
<Label Content="{Binding Size}" />
<Slider Value="{Binding Path=Size}" />
スライダは、デバッガで見られるようにモデルの値を変更します。しかし、ラベルの内容は変更されません。
どうすればよいですか?
TIA
あなたのサイズ呼び出しはOnPropertyChangeですか? MSが「Label.Contentプロパティへのデータバインドを避ける」と言う方法で、https://msdn.microsoft.com/en-us/library/bb613560%28v=vs.100%29.aspx代わりにtextblockを使用する – adminSoftDK