I'm using MVVM pattern in WPF. My small project contains 1x Window and 3x UserControls. Each UserControl represents tab, please see the picture below.
Solution structure
What I'm trying to do is to bind the Window Title to the variable in each tab model. I tried to use Interaction.Triggers and event name "Loaded". The command "ChangeTitle" works fine when I switch between different views but when I select tab with the same view as previously selected tab then title doesn't change until I switch to another tab with different view. I tried other events but couldn't find any for this purpose. I would like to trigger the above command after tab selection changed. Please advise. Thank you.
MainWindow.xaml
<Window x:Class="LSS_doc.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:intr="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:models="clr-namespace:LSS_doc.Models"
xmlns:Views="clr-namespace:LSS_doc.Views"
mc:Ignorable="d"
Height="350" Width="525"
MinHeight="350"
MinWidth="525">
<Grid>
<intr:Interaction.Triggers>
<intr:EventTrigger EventName="Loaded">
<intr:InvokeCommandAction Command="{Binding CreateMainTab}"/>
</intr:EventTrigger>
</intr:Interaction.Triggers>
<DockPanel>
<TabControl Name="tabControl" ItemsSource="{Binding Tabs}" SelectedIndex="{Binding TabIndex}">
<TabControl.Resources>
<DataTemplate DataType="{x:Type models:MainTabModel}">
<Views:MainTabView/>
</DataTemplate>
<DataTemplate DataType="{x:Type models:ResultTabModel}">
<Views:ResultTabView/>
</DataTemplate>
<DataTemplate DataType="{x:Type models:DisplayTabView}">
<Views:DisplayTabView/>
</DataTemplate>
</TabControl.Resources>
<TabControl.ItemTemplate>
<DataTemplate DataType="{x:Type models:ITabModel}">
<TextBlock>
<Run Text="{Binding Name}"/>
<Hyperlink Command="{Binding CloseCommand}" ><Run Text="{Binding CloseButton}"/></Hyperlink>
</TextBlock>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
</DockPanel>
</Grid>
MainTabView.xaml
<UserControl x:Class="LSS_doc.Views.MainTabView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:intr="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<intr:Interaction.Triggers>
<intr:EventTrigger EventName="Loaded">
<intr:InvokeCommandAction CommandParameter="{Binding Name}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ChangeTitle}"/>
</intr:EventTrigger>
</intr:Interaction.Triggers>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox Name="searchBox" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Keywords}" Margin="10,10,10,10" Height="30"/>
<Button Name="searchButton" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Search}" Grid.Column="1" Margin="0,0,10,0" Height="30"/>
<TreeView Grid.Row="1" Grid.ColumnSpan="2" Margin="10,0,10,10" BorderThickness="0">
<TreeViewItem Header="{Binding Name}" IsExpanded="True">
<TreeViewItem Header="Level 2.1" />
<TreeViewItem Header="Level 2.2" IsExpanded="True">
<TreeViewItem Header="Level 3.1" />
<TreeViewItem Header="Level 3.2" />
</TreeViewItem>
<TreeViewItem Header="Level 2.3" />
</TreeViewItem>
</TreeView>
</Grid>
ResultTabView.xaml
<UserControl x:Class="LSS_doc.Views.ResultTabView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:intr="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<intr:Interaction.Triggers>
<intr:EventTrigger EventName="Loaded">
<intr:InvokeCommandAction CommandParameter="{Binding Name}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ChangeTitle}"/>
</intr:EventTrigger>
</intr:Interaction.Triggers>
<Grid>
<ListBox x:Name="FileList" ItemsSource="{Binding Result}">
<ListBox.ItemTemplate>
<DataTemplate DataType="string">
<TextBlock>
<Hyperlink CommandParameter="{Binding}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.DisplayFile}">
<TextBlock Text="{Binding}"/>
</Hyperlink>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
DisplayTabView.xaml
<UserControl x:Class="LSS_doc.Views.DisplayTabView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:intr="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:LSS_doc.Helpers"
xmlns:ns="clr-namespace:LSS_doc.Helpers"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<intr:Interaction.Triggers>
<intr:EventTrigger EventName="Loaded">
<intr:InvokeCommandAction CommandParameter="{Binding Name}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ChangeTitle}"/>
</intr:EventTrigger>
</intr:Interaction.Triggers>
<Grid >
<WebBrowser local:WebBrowserExtensions.BindableSource="{Binding FileUrl}" local:WebBrowserExtensions.BindableLoaded="{Binding AcceptedKeywords}"/>
</Grid>
You can bind Window Title directly to model using ElementName:
<Window Title="{Binding ElementName=tab,Path=SelectedItem.WindowTitleForThisTab}">
Related
I have a reusable custom control for search results. It uses ListView GridView to display the search results and it's already used in multiple places in my app.
<views:AbstractDictionaryPickerView x:Class="MyApp.Common.Controls.Dictionaries.Views.AbstractDictionaryPickerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:watermark="clr-namespace:MyApp.Common.Controls.Watermark"
xmlns:behaviors="clr-namespace:MyApp.Common.Behaviors"
xmlns:listViewLayout="clr-namespace:Itenso.Windows.Controls.ListViewLayout;assembly=Itenso.Windows.Controls.ListViewLayout"
xmlns:views="clr-namespace:MyApp.Common.Controls.Dictionaries.Views"
xmlns:viewModels="clr-namespace:MyApp.Common.Controls.Dictionaries.ViewModels"
xmlns:design="clr-namespace:MyApp.Common.Controls.Dictionaries.ViewModels.Design"
d:DataContext="{design:DesignMultiDictionaryPickerViewModel}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Viewbox Stretch="Fill">
<Canvas Width="800" Height="800">
<Rectangle Fill="#ffffffff" Width="800" Height="800" />
<Rectangle Width="5" Height="800" >
<Rectangle.Fill>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFCAEBF4"/>
<GradientStop Color="#FFCEF5FF" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Canvas>
</Viewbox>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<TextBox
Grid.Row="0" Height="Auto"
Margin="5,0,5,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding SearchQuery, UpdateSourceTrigger=PropertyChanged}">
<i:Interaction.Behaviors>
<watermark:TextBoxWatermarkBehavior Label="{Binding WatermarkText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
LabelStyle="{StaticResource WatermarkStyle}"/>
<behaviors:SelectAllWhenTextBoxFocusedBehavior/>
<behaviors:TextBoxArrowUpDownNavigationBehavior/>
<behaviors:SetLogicalFocusBehavior/>
</i:Interaction.Behaviors>
</TextBox>
<Grid Grid.Row="1">
<ListView listViewLayout:ListViewLayoutManager.Enabled="True" x:Name="SearchResultsList"
ItemsSource="{Binding FilteredElements}"
ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="5,2,5,3"
SelectionMode="Single"
>
<ListView.Resources>
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource TextBlockStyle}"/>
</ListView.Resources>
<i:Interaction.Behaviors>
<behaviors:ArrowNavigationBehavior/>
<behaviors:AutoSizeListViewColumns/>
</i:Interaction.Behaviors>
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDoubleClick">
<i:InvokeCommandAction Command="{Binding ChooseItemCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, Path=SelectedItem}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListView.InputBindings>
<KeyBinding Key="Enter"
Command="{Binding ChooseItemCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, Path=SelectedItem}" />
<MouseBinding MouseAction="LeftDoubleClick"
Command="{Binding ChooseItemCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, Path=SelectedItem}" />
</ListView.InputBindings>
<ListView.View>
<!-- GRIDVIEW TO REPLACE -->
<GridView ColumnHeaderContainerStyle="{StaticResource {x:Type GridViewColumnHeader}}" x:Name="ElementsGridView">
<GridViewColumn Header="">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="viewModels:ChoosableViewModel">
<CheckBox IsChecked="{Binding IsChosen}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Grid>
</Grid>
</views:AbstractDictionaryPickerView>
The consuming code looks like that:
<UserControl x:Class="MyApp.Modules.Management.OnlineRegistrationSettings.Tabs.AvailableDoctors.OnlineRegistrationDoctorsSettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:views="clr-namespace:MyApp.Common.Controls.Dictionaries.Views;assembly=MyApp.Common"
xmlns:onlineRegistrationSettings="clr-namespace:MyApp.Modules.Management.OnlineRegistrationSettings"
d:DataContext="{d:DesignInstance onlineRegistrationSettings:OnlineRegistrationSettingsViewModel}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Style="{StaticResource LabelStyle}" Content="Wybór lekarzy, którzy mają być dostępni w rejestracji online."/>
<!-- HERE -->
<views:AbstractDictionaryPickerView DataContext="{Binding MultiDictionaryPickerViewModel}" Grid.Row="1"
Configuration="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.Configuration}"/>
</Grid>
</UserControl>
Now I want do modify the GridView columns (add a new column with ComboBox).
Is it possible to override the GridView element of the views:AbstractDictionaryPickerView in the XAML of the consuming code? I mean what's below <!-- GRIDVIEW TO REPLACE --> tag in the first snippet.
Is it possible to override the GridView element of the views:AbstractDictionaryPickerView in the XAML of the consuming code?
No. At least not using only XAML.
But if you add a property to your AbstractDictionaryPickerView control that exposes the view of the ListView:
public partial class AbstractDictionaryPickerView : UserControl
{
public AbstractDictionaryPickerView()
{
InitializeComponent();
}
public ViewBase GridView
{
get { return SearchResultsList.View; }
set { SearchResultsList.View = value; }
}
}
...you could set the it to a new GridView in the consuming XAML markup:
<views:AbstractDictionaryPickerView>
<views:AbstractDictionaryPickerView.GridView>
<GridView>
<GridView.Columns>
<GridViewColumn Header="..." DisplayMemberBinding="{Binding}" />
</GridView.Columns>
</GridView>
</views:AbstractDictionaryPickerView.GridView>
</views:AbstractDictionaryPickerView>
I am trying to bind to an element from a context menu inside a drop-down menu button (from http://shemesh.wordpress.com/2011/10/27/wpf-menubutton/). Even though outside the context menu the binding seems to work, the binding inside the context menu does not.
This is the XAML (very simplified):
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" CanContentScroll="False">
<ListBox x:Name="lbScenarios" HorizontalContentAlignment="Stretch">
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ItemsPresenter Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualWidth}"/>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border>
<Expander>
<Expander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Margin="5,0,0,0" Grid.Column="0" VerticalAlignment="Center">Results</TextBlock>
<local:MenuButton Grid.Column="3" Content="Menu" Margin="5,0,0,0" VerticalAlignment="Center">
<local:MenuButton.Menu>
<ContextMenu>
<MenuItem Header="Save pie chart as image"
Command="{Binding SaveChartImageCommand}"
CommandParameter="{Binding ElementName=pieChart}" />
<MenuItem Header="Save bar chart as image"
Command="{Binding SaveChartImageCommand}"
CommandParameter="{Binding ElementName=barChart}" />
</ContextMenu>
</local:MenuButton.Menu>
</local:MenuButton>
</Grid>
</Expander.Header>
<Expander.Content>
<StackPanel>
<Image x:Name="pieChart" />
<Image x:Name="barChart" />
</StackPanel>
</Expander.Content>
</Expander>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
</ScrollViewer>
</Grid>
</Window>
The binding that does not work is the {Binding ElementName=pieChart}, which is funny because the command is being found. I couldn't seem to get a RelativeSource to work, but can someone help me with getting the binding correct?
Since ContextMenu doesn't lie in same Visual tree as that of its placement target so ElementName binding won't work because it requires both controls to be in same Visual tree.
Try using x:Reference which doesn't have this constraint of to be in same visual tree.
CommandParameter="{Binding Source={x:Reference pieChart}}"
OR
use it like this
CommandParameter="{x:Reference pieChart}"
Note - x:Reference will be found in WPF 4.0 or later.
I am noob in WPF. I have a tab control with an icon on the tabs. When I import it by ElementHost the control in winforms, the icon does not appear on the tab. I load the icon image from Resource.
XAML Code:
<UserControl x:Class="WPF_Prueba.TabControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary>
<BitmapImage x:Key="tabIcon" UriSource="/Resources/delete.png" />
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<TabControl Name="tabDynamic" ItemsSource="{Binding}" SelectionChanged="tabDynamic_SelectionChanged">
<TabControl.Resources>
<DataTemplate x:Key="TabHeader" DataType="TabItem">
<DockPanel>
<Button Name="btnDelete" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" DockPanel.Dock="Right" Background="Transparent" Margin="5,0,-3,0" Padding="0" Click="btnDelete_Click" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=Name}">
<Image Source="{StaticResource tabIcon}" Height="10" Width="10"></Image>
</Button>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=TabItem}, Path=Header}" />
</DockPanel>
</DataTemplate>
</TabControl.Resources>
</TabControl>
</Grid>
</UserControl>
If anyone can help me please. Sorry for typos.
Best regards.
Make sure your png file has it's Build Action set to Resource:
I have the following code. I am trying to bind the Command property of the MenuItem to the relevant command which is implemented in the DataContext of the user control. Can anyone help me? The command does not get executed.
<UserControl x:Class="MIB2.App.Presentations.Views.CategoryManView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:model="clr-namespace:MIB2.Models;assembly=MIB2"
xmlns:local="clr-namespace:MIB2.App.Presentations.Views"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="335">
<UserControl.Resources>
<local:DatabindingDebugConverter x:Key="debugConverter" />
</UserControl.Resources>
<StackPanel Width="417">
<TreeView x:Name="tree"
ItemsSource="{Binding RootCategories}" SelectedItemChanged="TreeView_SelectedItemChanged"
MouseRightButtonDown="OnPreviewMouseRightButtonDown">
<TreeView.ContextMenu>
<ContextMenu>
<MenuItem Header="Add Root Category" Command="{Binding AddRootCategoryCommand}"/>
</ContextMenu>
</TreeView.ContextMenu>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate DataType="model:Item"
ItemsSource="{Binding Children}">
<Grid>
<Grid.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget.Tag, RelativeSource={RelativeSource AncestorType=TextBox}}">
<MenuItem Header="Add Category" Command="{Binding Path=AddEntityCommand}" />
</ContextMenu>
</Grid.ContextMenu>
<TextBlock Text="{Binding Description}" Margin="0,0,10,0" Tag="{Binding DataContext, ElementName=tree}"/>
</Grid>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<StackPanel Orientation="Horizontal">
<Button Content="Add New Category" Command="{Binding AddEntityCommand}" />
<Button Content="Add New Root Category" Command="{Binding AddRootCategoryCommand}" />
<Button Content="Delete Category" Command="{Binding DeleteEntityCommand}" />
</StackPanel>
<ContentControl Content="{Binding EntityViewModel.View}" />
</StackPanel>
</UserControl>
Please try this:
<TreeView.ItemTemplate>
<HierarchicalDataTemplate DataType="model:Item"
ItemsSource="{Binding Children}">
<Grid Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType=UserControl}}">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Add Category"
Command="{Binding Path=PlacementTarget.Tag.AddEntityCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}" />
</ContextMenu>
</Grid.ContextMenu>
<TextBlock Text="{Binding Description}" Margin="0,0,10,0" />
</Grid>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
You can use RelativeSource in binding to lookup the parent object
e.g
<MenuItem Header="Add Root Category" Command="{Binding DataContext.CommandName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}/>
I have a TabItem that has it's DataContext set to a ViewModel.
The header is set to a header View and the Content is set to an item view
However this Binding from the item view just doesn't work
<TextBox Margin="0" Grid.Column="0" Grid.Row="0" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=sdk:TabItem, AncestorLevel=1}, Path=DataContext.Job.SourceCode, Mode=TwoWay}"/>
yet this binding
<TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=sdk:TabItem, AncestorLevel=1}, Path=DataContext.Job.Name}"/>
which is in the header view works fine.
I've even tried putting the TextBlock from the Header into the Item and setting the Content to a new HeaderView. No matter what I try I can't get the bindings from the Content to work even though the header binding works fine
Can anyone explain?
Adding the full Views as requested first the Item
<UserControl x:Class="IE.Intergration.JobBuilder.Views.TabbedJobs.TabbedJobItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"
DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=New.TabbedJobs.TabbedJobItem}"
>
<UserControl.Resources>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" >
<Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<TextBox Margin="0" Grid.Column="0" Grid.Row="0" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=sdk:TabItem, AncestorLevel=1}, Path=DataContext.Job.SourceCode, Mode=TwoWay}"/>
<StackPanel Grid.Column="0" Grid.Row="1" FlowDirection="LeftToRight" Orientation="Horizontal">
<Button Content="Save" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=sdk:TabItem, AncestorLevel=1}, Path=DataContext.Save}" />
</StackPanel>
</Grid>
and the Header
<UserControl x:Class="IE.Intergration.JobBuilder.Views.TabbedJobs.TabbedJobItemHeader"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"
DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=New.TabbedJobs.TabJobHeader}"
>
<Grid x:Name="LayoutRoot">
<TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=sdk:TabItem, AncestorLevel=1}, Path=DataContext.Job.Name}"/>
</Grid>