Skip to content

Instantly share code, notes, and snippets.

@VijayChuhan VijayChuhan/RoomGroupXaml Secret
Created Feb 18, 2016

Embed
What would you like to do?
How to access Parent element DataContext to Child
<TabItem Margin="-40,0,0,0" Height="50" Width="Auto" Style="{DynamicResource CenterTabItem}" >
<TABITEM.DATACONTEXT>
<VIEWMODEL:ROOMANDROOMGROUPVIEWMODEL/>
</TABITEM.DATACONTEXT>
<Grid VerticalAlignment="Stretch">
<GRID.RESOURCES>
<MODELS:BINDINGPROXY X:KEY="PROXY" DATA="{BINDING}"/>
</GRID.RESOURCES>
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<Grid Grid.Row="0" VerticalAlignment="Stretch" Name="grdDashboard">
<Border Grid.Row="2" VerticalAlignment="Top" BorderThickness="2,1,2,2" BorderBrush="LightGray">
<!--LISTVIEW TO GENERATE ROOMGROOPS-->
<LISTVIEW NAME="LSTROOMGROUPLIST" ITEMSSOURCE="{BINDING ROOMGROUPLIST,MODE=TWOWAY}" SELECTEDITEM="{BINDING SELECTDEGROUP,MODE=TWOWAY}"
HORIZONTALALIGNMENT="LEFT" VERTICALALIGNMENT="TOP" BACKGROUND="TRANSPARENT">
<ListView.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Left" VerticalAlignment="Stretch" Background="#74BF94">
<!--UpperControl-->
<Border Name="grdEditRoom" Grid.Row="0" Width="Auto" BorderBrush="#74BF94" Visibility="{Binding IsCollapsed,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource BooleanToVisibilityConverter}}"
BorderThickness="2,1,1,1" Margin="5,0,-5,2" Background="White" Grid.ColumnSpan="3">
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Horizontal">
<Border Grid.Column="0" Grid.Row="0" BorderThickness="0,0,1,0" BorderBrush="LightGray" Width="18">
<Grid x:Name="lblCollapse" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="17">
I WANT TO ACCESS CMDEXPAND ON THIS BUTTON
<BUTTON GRID.ROW="1" VERTICALALIGNMENT="CENTER" HEIGHT="12" WIDTH="12" HORIZONTALALIGNMENT="CENTER" COMMAND="{BINDING}"></BUTTON>
</Grid>
</Border>
<TextBox Width="80" Height="40" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding GroupName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Name="tbEditGroupName" TextWrapping="Wrap" Margin="0,5,0,0">
</TextBox>
<Label Name="lblTimeZone" Foreground="Gray" HorizontalAlignment="Left" Height="35" Margin="-90,40,0,0" >Time zone:</Label>
<ComboBox Width="90" Name="cbTimeZone" DisplayMemberPath="TimeZone" Height="25" Margin="-90,75,0,0" HorizontalAlignment="Left" SelectedValuePath="Key"></ComboBox>
<!--ROOMLIST IN ROOMGROUPLIST-->
"HERE I WANT TO BIND ROOMLIST WITH VIEWMODEL'S ITEMSOURCE BUT CAN'T ACCESS ""DATA.ROOMLIST" HERE ..."
<LISTVIEW X:NAME="LSTROOMLIST" GRID.ROW="3" ITEMSSOURCE="{BINDING }" SELECTEDITEM="{BINDING SELECTEDROOM,MODE=TWOWAY}">
</ListView>
</StackPanel>
</Border>
<!--LOWERCONTROL-->
<Border Name="grdViewRoom" Width="Auto" Grid.Row="1" BorderBrush="LightGray" BorderThickness="0,1,0,1" Grid.ColumnSpan="3">
<Grid Height="50" Background="#F3F3F5" VerticalAlignment="Stretch">
<Grid x:Name="lblExpand" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Stretch" Background="#F3F3F5" Grid.ColumnSpan="3" Width="20">
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Transparent"></Label>
I CAN ACCESS CMDEXPAND HERE...!
<BUTTON GRID.ROW="1" COMMAND="{BINDING DATA.CMDEXPAND,SOURCE={STATICRESOURCE PROXY}}" MARGIN="7,0,1,0" WIDTH="12" HEIGHT="12" BACKGROUND="TRANSPARENT" BORDERTHICKNESS="0" VERTICALALIGNMENT="TOP"></BUTTON>
<Image Source="/Images/ArrowRight.png" Grid.Row="1" Margin="7,0"></Image>
<Label Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Background="Transparent" Height="19" ></Label>
</Grid>
<TextBox Grid.Column="3" Width="80" Height="35" HorizontalAlignment="Right" Background="#F3F3F5" TextBlock.TextAlignment="Center" BorderThickness="0"
Name="tbGroupName" VerticalAlignment="Bottom" TextWrapping="Wrap"
Text="{Binding GroupName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.ColumnSpan="2" Margin="0,0,6,0" ></TextBox>
<TextBox Grid.Column="6" Name="txtRoomNameDisable" Visibility="Hidden" HorizontalAlignment="Center" VerticalAlignment="Center" Width="80" MaxLength="23" Margin="2,16,3,16"></TextBox>
<!--Start: Vertical lines-->
</Grid>
</Border>
</Border>
<UserConrols:ErrorMessage Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="4" x:Name="ErrorMessageControl" HorizontalAlignment="Stretch"/>
</Grid>
</TabItem>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.