In MainPage.xaml I have 2 canvas controls (bd1 and ball) that represent 2 layers. - <Canvas x:Name="ContentCanvas" Width="354" Height="669">
-
<Canvas.Background>
-
<RadialGradientBrush>
-
<GradientStop Color="#FF9D0A0A" Offset="0" />
-
<GradientStop Color="Black" Offset="1" />
-
</RadialGradientBrush>
-
</Canvas.Background>
-
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-
x:Name="bd1" Width="370" Height="480" Clip="F1 M 0,0L 640,0L 640,480L 0,480L 0,0" MouseMove="Canvas_MouseMove" HorizontalAlignment="Left" VerticalAlignment="Top">
-
<Canvas.RenderTransform>
-
<TransformGroup>
-
<RotateTransform Angle="0" CenterX="0.5" CenterY="0.5" />
-
<TranslateTransform X="0" Y="0" />
-
<ScaleTransform ScaleX="1" ScaleY="1" />
-
<SkewTransform AngleX="0" AngleY="0"/>
-
</TransformGroup>
-
</Canvas.RenderTransform>
-
<Path....../>
-
........
-
</Canvas>
-
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="ball"
-
Width="54" Height="52.5" Clip="F1 M 0,0L 54,0L 54,52.5L 0,52.5L 0,0"
-
MouseMove="Canvas_MouseMove" HorizontalAlignment="Left" VerticalAlignment="Top">
-
<Canvas.RenderTransform>
-
<TransformGroup>
-
<RotateTransform Angle="0" CenterX="0.5" CenterY="0.5" />
-
<TranslateTransform X="0" Y="0" />
-
<ScaleTransform ScaleX="1" ScaleY="1" />
-
<SkewTransform AngleX="0" AngleY="0"/>
-
</TransformGroup>
-
</Canvas.RenderTransform>
-
<Canvas Width="640" Height="480.425" Canvas.Left="0" Canvas.Top="0">
-
<Ellipse x:Name="Ellipse" Width="54" Height="52.5" Canvas.Left="4.17233e-007" Canvas.Top="2.03252e-005" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFF0000">
-
<Ellipse.Fill>
-
<LinearGradientBrush StartPoint="0.0633299,0.762378" EndPoint="0.93667,0.237621">
-
<LinearGradientBrush.GradientStops>
-
<GradientStop Color="#FF000000" Offset="0"/>
-
<GradientStop Color="#FFFFFFFF" Offset="1"/>
-
</LinearGradientBrush.GradientStops>
-
</LinearGradientBrush>
-
</Ellipse.Fill>
-
</Ellipse>
-
</Canvas>
-
</Canvas>
For that I created a class called Layer that has a Canvas property : - public class Layer
-
{
-
public Layer() { }
-
public Layer(Canvas canvas, Tipologie tip)
-
{
-
ThisCanvas = canvas; Tip = tip;
-
}
-
public string Name { get; set; }
-
private Canvas canv;
-
public Canvas ThisCanvas
-
{
-
get { return canv; }
-
set
-
{
-
canv = value;
-
if (value != null)
-
Name = value.GetValue(Canvas.NameProperty) as string;
-
}
-
}
-
}
In the MainPage class I have a global collection of Layer type. Initially I put in the collection 2 layers. - private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
-
{
-
Layers[0] = new Layer(); Layers[0].ThisCanvas = GetTemplateChild("bd1") as Canvas;
-
Layers[1] = new Layer(); Layers[1].ThisCanvas = ball;
-
LayerSelector.ItemsSource = Layers;
-
}
-
Layer[] Layers = new Layer[2];
The problem is that bd1 and ball canvas controls are null . I also tried to put the code in the constructor of the page but it was the same problem.
I can't explain that.
Am I doing something wrong? Thanks in advance!
0 1426 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: headware |
last post by:
I have a user control that is basically a Datagrid with a few
additional controls for filtering the data and showing/hiding columns.
I'd like to be able to reuse this control in different places
throughout my code but allow it to work with different tables in the
database.
I thought that I would use the Template pattern to achieve this. I put
all the functions in an abstract base class which inherited from
UserControl except a...
|
by: Randall Parker |
last post by:
In places where ASP.Net does the handling of controls for you does it treat controls
as null or as zero length strings?
|
by: AricC |
last post by:
Currently I am manually setting each control on my form to null to reset. Does anyone know how to do this with a loop or a more simple command? I've seen some make shift control arrays but none that would work for me.
Thanks,
Aric
|
by: kalaivanan |
last post by:
hi,
i am trying to add a datagrid control to a web page dynamically.
i am able to do it while i used the following code in the page load
event of the form in which i am going to add the control.
DataGrid dG = new DataGrid();
Control frm = FindControl("frmSnAInformation");
frm.Controls.Add(dG);
DataSet ds = nam_Db.dbFunctions.funFetchDataSet("fetchSuInfo_all");
dG.DataSource = ds.Tables;
|
by: Jon Davis |
last post by:
OK, why is Canvas not IDisposable, and how do I get rid of all the Windows
handles?
I'm doing a performance test of looping through a dynamic XAML-to-JPEG
conversion. It gets to about 500 conversions and then crashes. Task Manager
says that about 6000 Windows handles were created and the count never
decrements.
My code (loop not shown):
| |
by: germ |
last post by:
I am moving a web application from 1.1 to 2.0
This site builds pages dynamically as :
PlaceHolder.Controls.Add(LoadControl("~/Controls/Ctl1.ascx"));
Everything is working fine as long as the web site is updateable - the .ascx
files exist on disk.
I would like to use the non-updateable and single assembly options - no
..ascx files.
I thought that maybe this would work :...
|
by: =?Utf-8?B?a2V2aW4=?= |
last post by:
using VS2005
My masterpage has two panels and two hyperlinks. The initial content aspx
page is blank.
The page_load event of the masterpage hides one of the panels based on
SESSION variables.
When I press one particular link all controls are null, thus throwing an
error. The other hyperlink behaves normally.
|
by: binky |
last post by:
Quick question that I can't find a solution to:
I have an ADP application that uses SQL Server 2000 backend, along with stored procedures that populate my forms. I do not want to use subforms for various reasons, so my data is loaded into a single form (record source is a stored procedure, and the form's InputParameters are changed depending on the data to load, pretty standard).
However, if no records are returned by the procedure, all...
|
by: ilya Kraft |
last post by:
Hello, i found this cool HTML5 feature called Gradient canvas. I would like to use it as a website background, is it possible to somehow place content on it? when i use divs and table nothing appears only this canvas.
Here is a file i want to use as a background.
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>ilya daderko</title>
<style>
|
by: ilya Kraft |
last post by:
Hello I have this interactive canvas as a background of my web, it is on 100% width and high, but when I add content that continues longer than canvas and you have to scroll down, canvas is not repeating down y axis.
Also can anyone tell how can i center align absolute positioned <div>.
I added white box that is longer than canvas, if you scroll down you start to see black background, how can I make canvas repeat down y-axis and how do i...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |