Hello,
I have a problem of entrapment event
"PropertyChanging" in MVVM.
Moj intent is that after undocking
(IsFloating = true) "LayoutDocument" and
other changes to the properties as is the
case of this event without using the
MVVM pattern "myLayoutDocument.PropertyChanging
+ = new PropertyChangingEventHandler
(ldStart_PropertyChanging)," I wanted to
capture this event. They tried
it according to example I AvalonDock
with MVVM from there and
when I define "LayoutItemContainerStyleSelector" ...
<style TargetType="{x:Type avalondock:LayoutItem}">
the event "PropertyChanging"
not present. Please advice how it
can fix.
For nearly a reply in advance thanx
Forgive me my English
Source: www.martin-mandak.com/MassWindows.rar
class MainViewModels : ViewModelBase<MainViewModels> { #region Properties private ObservableCollection<LayoutDocument> _documentSource; public ObservableCollection<LayoutDocument> DocumentSource { get { return _documentSource; } set { if (_documentSource != value) { _documentSource = value; OnPropertyChanged(o => o.DocumentSource); } } } #endregion public MainViewModels() { Uri cestaStart = new Uri(@"\Images\Icons\forward_green.png", UriKind.Relative); LayoutDocument ldStart = new LayoutDocument(); ldStart.Title = "Start Page"; ldStart.Description = "TRUE"; ldStart.Content = new StartPage(); ldStart.IconSource = cestaStart; //this is the problem //----------------// ldStart.PropertyChanging += new PropertyChangingEventHandler(ldStart_PropertyChanging); //----------------// DocumentSource = new ObservableCollection<LayoutDocument>(); DocumentSource.Add(ldStart); } void ldStart_PropertyChanging(object sender, PropertyChangingEventArgs e) { } }
and XAML:
<Window.Resources> <mvvm:MainViewModels x:Key="MainViewModels" /> </Window.Resources> <Grid x:Name="grid" DataContext="{StaticResource MainViewModels}"> <Grid.RowDefinitions> <RowDefinition Height="24"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Menu x:Name="menu" Grid.Row="0" /> <avalondock:DockingManager x:Name="rootDM" Grid.Row="1" DocumentsSource="{Binding DocumentSource}" > <avalondock:DockingManager.Theme> <avalondock:VS2010Theme/> </avalondock:DockingManager.Theme> <avalondock:DockingManager.LayoutItemContainerStyleSelector> <mvvm:PanesStyleSelector> <mvvm:PanesStyleSelector.DockStyleStart> <Style TargetType="{x:Type avalondock:LayoutItem}"> <Setter Property="IsSelected" Value="True" /> <Setter Property="IsActive" Value="True" /> <Setter Property="IconSource" Value="{Binding Model.IconSource}"/> <Setter Property="ContentId" Value="{Binding Model.ContentId}"/> <Setter Property="Visibility" Value="{Binding Model.IsVisible}" /> <Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/> <Setter Property="Title" Value="{Binding Model.Title}"/> </Style> </mvvm:PanesStyleSelector.DockStyleStart> </mvvm:PanesStyleSelector> </avalondock:DockingManager.LayoutItemContainerStyleSelector> <avalondock:DockingManager.DocumentHeaderTemplateSelector> <mvvm:PanesTemplateSelector> <mvvm:PanesTemplateSelector.LayoutDocument> <DataTemplate> <StackPanel Orientation="Horizontal"> <Image Width="16" Source="{Binding IconSource}" Margin="0,0,10,0" /> <TextBlock Text="{Binding Title}"/> </StackPanel> </DataTemplate> </mvvm:PanesTemplateSelector.LayoutDocument> </mvvm:PanesTemplateSelector> </avalondock:DockingManager.DocumentHeaderTemplateSelector> <avalondock:DockingManager.LayoutItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="White"> <ContentControl Content="{Binding Content}"> </ContentControl> </StackPanel> </DataTemplate> </avalondock:DockingManager.LayoutItemTemplate> </avalondock:DockingManager> </Grid>