|
Hi, Pete
when I add the canvases to the main canvas, I am setting their top or left property through Canvas.SetTop(), Canvas.SetLeft().
I think that this way the new elements are assigned position.
At least the Top or Left Property should have values. But they are zero also.
|
|
|
|
|
|
Hi amitgajjar,
1)This is my user control that has a canvas in it. This is the user control I add into the parent canvas.
<UserControl x:Class="Aluminium.usercontrols.ShutterUI"
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:vm="clr-namespace:Aluminium.viewmodels"
xmlns:cnv="clr-namespace:Aluminium.converters"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" >
<UserControl.Resources>
<!--<cnv:DataSideToThicknessConverter x:Key="sideToThick" />-->
</UserControl.Resources>
<Canvas Name="VisualCanvas" Background="AliceBlue" VerticalAlignment="Stretch" Width="{Binding Path=OpticalWidth}" Height="{Binding Path=OpticalHeight}" >
<Border BorderThickness="{Binding Path=BorderThickness}" Name="CanvasBorder" BorderBrush="Black" Width="{Binding ElementName=VisualCanvas, Path=Width}" Height="{Binding ElementName=VisualCanvas, Path=Height}">
<Canvas Name="ShutterCanvas" Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" >
<StackPanel>
<Label Name="ShutterLabel" Content="{Binding Path=ShutterLabel}" />
<Label Name="ShutterHeightValue" VerticalAlignment="Center" HorizontalAlignment="Center" Content="{Binding Path=Height}" />
<Label Name="ShutterWidthValue" VerticalAlignment="Center" HorizontalAlignment="Center" Content="{Binding Path=Width}"/>
</StackPanel>
</Canvas>
</Border>
</Canvas>
</UserControl>
2) This is how I add this user control to the parent Canvas. VisualCanvas is the parent canvas. FocusedCanvas is a data object. Offset is the length in pixels from the top of the parent canvas, where I insert the child canvas. The counter (i) takes the value 1 or 2 because each time I add 2 canvases together.
this._helper.FocusedCanvas.VisualCanvas.Children.Add(sui);
Canvas.SetTop(this._helper.FocusedCanvas.VisualCanvas.Children[i], offset);
After that if I try to read the margins and top values for the user control itself I get :
a)((ShutterUI)(this._helper.FocusedCanvas.VisualCanvas.Children[i])).Margin = {0,0,0,0}
b)Canvas.GetTop(((ShutterUI)(this._helper.FocusedCanvas.VisualCanvas.Children[i]))) = 0.0
and if I try to read the margins and the top values of the included canvas I get :
a)((ShutterUI)(this._helper.FocusedCanvas.VisualCanvas.Children[i])).VisualCanvas.Margin = {0,0,0,0}
b)Canvas.GetTop(((ShutterUI)(this._helper.FocusedCanvas.VisualCanvas.Children[i])).VisualCanvas) = NaN
any help is appreciated
|
|
|
|
|
If you assign the Canvas locations, it doesn't have any effect on the position of the child elements because they are added at the default position of the Canvas they are added into. You need to explicitly set the position of the elements on the Canvas before you can get a position value.
|
|
|
|
|
i need help in creating a banking account register. I have to do this through Visual Basics. The register will include Account Name, Account Number, and Account Balance, and it will allow a user to enter deposit or withdrawal
information. Throughout the chapters, you were given all of the tools necessary to complete this task.
Use a flowchart to help with your decisions and the programming example in Chapter 9 to help with the
project. Good luck!
Rules
1. The initial graphical user interface should contain a label that contains your name and MEID#,
and it should provide two user interaction options: Enter Account Information and Clear.
2. When the user selects Enter Account Information, the graphical user interface should provide
three options: Account Name, Account Number, and Beginning Balance.
3. After the user enters the correct information, allow him/her to continue by using the Continue
Option.
4. The selection of Continue should provide the user with Withdrawal Amount and Deposit
Amount.
5. The Continue button selection should also make the label Beginning Balance read Available
Balance, and the text boxes in Account Information should become read‐only.
6. Allow users to enter Withdrawal Amount and Deposit Amount and change Account Balance
accordingly.
7. Clear Withdrawal and Deposit amounts/text boxes so users can continue to enter additional
amounts.
8. The user should be able to add as many withdrawals and deposits as he/she wants.
9. The Clear button should clear the program and return to Step 1 whenever it is selected.
|
|
|
|
|
Things you should avoid doing (all of which you have done):
- Ask us to do your homework.
- Make subject lines that give no indication of the contents of the message.
- Beg for help.
- Post the same message across multiple forums.
If you have a specific question, and you can ask it in a considerate manner, we'd be happy to help.
|
|
|
|
|
i will bookmark your reply. as so many ppl do the same mistake when posting their problems.
|
|
|
|
|
Member 9030645 wrote: Throughout the chapters, you were given all of the tools necessary to complete this task.
It says right there that you should be able to complete this on your own.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Member 9030645 wrote: i need help...
1. Read chapter 9. Review previous chapters as needed.
2. Write some code
3. Test it
4. Repeat steps 2/3 until you have completed the assignment.
Good luck!
|
|
|
|
|
Hi everybody
How can i send a mail in C#
|
|
|
|
|
|
Hi,
if you would like to send email using your gmail account with attachment using c# code, then please refer this link
-Amit
|
|
|
|
|
I have a class that gets it's startup path using the following:
String myPath = Application.StartupPath;
This worked fine with it's own test form, but once I was referring to this class from another class in a different directory, it returns the wrong directory. Is there a c# way to get the directory of the class and not the class that calls it?
Thanks for any help!
|
|
|
|
|
Console.Write(typeof(string).Assembly.Location);
Will the path, prolly including the assemblies name.
Bastard Programmer from Hell
|
|
|
|
|
Uh, surely that will tell you where mscorlib is?
|
|
|
|
|
Yes. Do you think I should have said that I used "string" as an example type?
Bastard Programmer from Hell
|
|
|
|
|
This has nothing to do with classes, it returns the path to the executable program as described here[^].
|
|
|
|
|
Assembly.GetExecutingAssembly().Location.
|
|
|
|
|
Surely, that returns the location of the executing assembly?
TopicStarter wrote: Is there a c# way to get the directory of the class and not the class that calls it?"
Bastard Programmer from Hell
|
|
|
|
|
Yes, but 'the class' surely refers to the current class, which will be in the executing assembly. That's how I read it, anyway.
|
|
|
|
|
Yup, sounds logical too. It must be either time for coffee, or for some sleep
Bastard Programmer from Hell
|
|
|
|
|
Thanks for the input, guys. See my clarification at the end here.
|
|
|
|
|
To clarify:
main program is in directory A
main program uses sub-program in directory B
I need to get the directory of B programatically.
Wouldn't anything referring to executing assembly refer to the location of main program in directory A? Since I am referring to program B in program A, the dll or exe is copied to program A's directory, so getting that location would return program A's location, not program B. I have a file I need to use/get in dir B.
A->B and B is trying to open a file in it's directory but I'm getting the location of A because A is the application startup path (and executing assembly,no?).
Sorry for the confusion! I hope that this makes it more clear!
modified 25-May-12 13:28pm.
|
|
|
|
|
Is directory of the B is relative to the A's directory then you can calculate the path for B's directory
get the App path and then add directories or remove directories depending on the B's location...
Assuming that B's directory does not change with respect to A's
Happy Coding
|
|
|
|
|
That's a good idea. A's directory is blah/blah1/blah2/tool/tool/bin/Debug and then B's directory could be found by appending it's location onto blah/blah1/blah2.
|
|
|
|