I'm having problem with my reaching, what i want to do is i want to reach this rectangle that is located in my UserControl
:
<Rectangle x:Name="StatusColor" Margin="0,0,0,0" Height="218" VerticalAlignment="Top">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#00000000" Offset="0.901"/>
<GradientStop Color="#CC17FF00" Offset="0"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
and be able to call it in my Main.xaml.cs
for example like this:
StatusColor.Fill = RedBrush;
Right now I just receiving an error that says:
The name 'StatusColor' does not exist in the current context
I have two Xaml files named Main.xaml
and the UserControl
that is named TemplateGrid.xaml
both files with one code behind file (Main.xaml.cs
and TemplateGrid.xaml.cs
)
So just to simplify.... I want to reach a X:name inside TemplateGrid.xaml
from Main.xaml.cs
.
Thanks in advance!
EDIT:
This is where i declare UserControl
inside Main.xaml
:
<GridView x:Name="GridView1" ItemContainerStyle="{StaticResource testGrid}" ItemsSource="{x:Bind testValue}" Width="1740" Height="835" IsHitTestVisible="False" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Margin="75,190,75,100" FontFamily="Segoe MDL2 Assets" IsDoubleTapEnabled="False" IsHoldingEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False">
<GridView.ItemTemplate>
<DataTemplate x:DataType="data:Room">
<local:TemplateGrid x:Name="TemplateGridControl"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>