how to use canvas.SetLeft on DateTime in wpfWhat is the correct way to create a single-instance WPF application?How do I use WPF bindings with RelativeSource?In WPF, what are the differences between the x:Name and Name attributes?WPF - ScreenSaver graphics performance improvementsHow do I exit a WPF application programmatically?Drawing lines and ellipses using ObservableCollection and ItemsControlWhy does a databinding for a Path's fill work but any binding for any of its child elements don't?How to draw simple shapes onto a WPF xaml-defined canvas programaticallyNew row in Binded DataGrid shows DatePicker as 01/01/0001How to WPF draw rectangle on top of image view dragged onto canvas
How do I find all files that end with a dot
Is it improper etiquette to ask your opponent what his/her rating is before the game?
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
What is Cash Advance APR?
Closed-form expression for certain product
Why electric field inside a cavity of a non-conducting sphere not zero?
Is the U.S. Code copyrighted by the Government?
How to implement a feedback to keep the DC gain at zero for this conceptual passive filter?
Which one is correct as adjective “protruding” or “protruded”?
Not using 's' for he/she/it
Why should universal income be universal?
Can I sign legal documents with a smiley face?
What does chmod -u do?
Is it safe to use olive oil to clean the ear wax?
Why is it that I can sometimes guess the next note?
Is there a working SACD iso player for Ubuntu?
Why is so much work done on numerical verification of the Riemann Hypothesis?
If a character has darkvision, can they see through an area of nonmagical darkness filled with lightly obscuring gas?
If infinitesimal transformations commute why dont the generators of the Lorentz group commute?
Are the IPv6 address space and IPv4 address space completely disjoint?
Melting point of aspirin, contradicting sources
Create all possible words using a set or letters
Is there a name for this algorithm to calculate the concentration of a mixture of two solutions containing the same solute?
What was the exact wording from Ivanhoe of this advice on how to free yourself from slavery?
how to use canvas.SetLeft on DateTime in wpf
What is the correct way to create a single-instance WPF application?How do I use WPF bindings with RelativeSource?In WPF, what are the differences between the x:Name and Name attributes?WPF - ScreenSaver graphics performance improvementsHow do I exit a WPF application programmatically?Drawing lines and ellipses using ObservableCollection and ItemsControlWhy does a databinding for a Path's fill work but any binding for any of its child elements don't?How to draw simple shapes onto a WPF xaml-defined canvas programaticallyNew row in Binded DataGrid shows DatePicker as 01/01/0001How to WPF draw rectangle on top of image view dragged onto canvas
Sesaonallist
is an ObservableCollection
of type DataPoint
.
I am trying to write each datapoint
within the observable collection as an ellipse and draw it to a canvas. The problem is that X axis
is of DateTime
and I get the error
cannot convert DateTime to double
when I use Canvas.SetLeft(ellipse, Seasonallist[i].X);
.
I don't want to use any third party libraries to do this, should i look into Converters?
Seasonallist = new ObservableCollection<DataPoint>();
if (Seasonallist != null)
for (int i = 0; i <= Seasonallist.Count - 1; i++)
Ellipse ellipse = new Ellipse();
ellipse.Width = 5;
ellipse.Height = 5;
ellipse.Fill = Brushes.Blue;
Canvas.SetLeft(ellipse, Seasonallist[i].X); <--error here
Canvas.SetTop(ellipse, Seasonallist.Y);
textCanvas.Children.Add(ellipse);
public class DataPoint
public DateTime X get; set;
public double Y get; set;
wpf
add a comment |
Sesaonallist
is an ObservableCollection
of type DataPoint
.
I am trying to write each datapoint
within the observable collection as an ellipse and draw it to a canvas. The problem is that X axis
is of DateTime
and I get the error
cannot convert DateTime to double
when I use Canvas.SetLeft(ellipse, Seasonallist[i].X);
.
I don't want to use any third party libraries to do this, should i look into Converters?
Seasonallist = new ObservableCollection<DataPoint>();
if (Seasonallist != null)
for (int i = 0; i <= Seasonallist.Count - 1; i++)
Ellipse ellipse = new Ellipse();
ellipse.Width = 5;
ellipse.Height = 5;
ellipse.Fill = Brushes.Blue;
Canvas.SetLeft(ellipse, Seasonallist[i].X); <--error here
Canvas.SetTop(ellipse, Seasonallist.Y);
textCanvas.Children.Add(ellipse);
public class DataPoint
public DateTime X get; set;
public double Y get; set;
wpf
add a comment |
Sesaonallist
is an ObservableCollection
of type DataPoint
.
I am trying to write each datapoint
within the observable collection as an ellipse and draw it to a canvas. The problem is that X axis
is of DateTime
and I get the error
cannot convert DateTime to double
when I use Canvas.SetLeft(ellipse, Seasonallist[i].X);
.
I don't want to use any third party libraries to do this, should i look into Converters?
Seasonallist = new ObservableCollection<DataPoint>();
if (Seasonallist != null)
for (int i = 0; i <= Seasonallist.Count - 1; i++)
Ellipse ellipse = new Ellipse();
ellipse.Width = 5;
ellipse.Height = 5;
ellipse.Fill = Brushes.Blue;
Canvas.SetLeft(ellipse, Seasonallist[i].X); <--error here
Canvas.SetTop(ellipse, Seasonallist.Y);
textCanvas.Children.Add(ellipse);
public class DataPoint
public DateTime X get; set;
public double Y get; set;
wpf
Sesaonallist
is an ObservableCollection
of type DataPoint
.
I am trying to write each datapoint
within the observable collection as an ellipse and draw it to a canvas. The problem is that X axis
is of DateTime
and I get the error
cannot convert DateTime to double
when I use Canvas.SetLeft(ellipse, Seasonallist[i].X);
.
I don't want to use any third party libraries to do this, should i look into Converters?
Seasonallist = new ObservableCollection<DataPoint>();
if (Seasonallist != null)
for (int i = 0; i <= Seasonallist.Count - 1; i++)
Ellipse ellipse = new Ellipse();
ellipse.Width = 5;
ellipse.Height = 5;
ellipse.Fill = Brushes.Blue;
Canvas.SetLeft(ellipse, Seasonallist[i].X); <--error here
Canvas.SetTop(ellipse, Seasonallist.Y);
textCanvas.Children.Add(ellipse);
public class DataPoint
public DateTime X get; set;
public double Y get; set;
wpf
wpf
edited Mar 8 at 6:31
RN92
926724
926724
asked Mar 8 at 4:34
masterinexmasterinex
1622311
1622311
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
you can try the Ticks
Property of the DataTime
.
Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));
you have to find a good way to convert this big number into X Canvas coordination.
okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?
– masterinex
Mar 8 at 10:14
add a comment |
Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:
TicksPerPixel is Display duration / Display Width
You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056776%2fhow-to-use-canvas-setleft-on-datetime-in-wpf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can try the Ticks
Property of the DataTime
.
Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));
you have to find a good way to convert this big number into X Canvas coordination.
okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?
– masterinex
Mar 8 at 10:14
add a comment |
you can try the Ticks
Property of the DataTime
.
Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));
you have to find a good way to convert this big number into X Canvas coordination.
okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?
– masterinex
Mar 8 at 10:14
add a comment |
you can try the Ticks
Property of the DataTime
.
Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));
you have to find a good way to convert this big number into X Canvas coordination.
you can try the Ticks
Property of the DataTime
.
Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));
you have to find a good way to convert this big number into X Canvas coordination.
answered Mar 8 at 6:35
Hakam FostokHakam Fostok
5,61284469
5,61284469
okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?
– masterinex
Mar 8 at 10:14
add a comment |
okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?
– masterinex
Mar 8 at 10:14
okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?
– masterinex
Mar 8 at 10:14
okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?
– masterinex
Mar 8 at 10:14
add a comment |
Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:
TicksPerPixel is Display duration / Display Width
You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.
add a comment |
Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:
TicksPerPixel is Display duration / Display Width
You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.
add a comment |
Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:
TicksPerPixel is Display duration / Display Width
You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.
Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:
TicksPerPixel is Display duration / Display Width
You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.
edited Mar 8 at 10:24
answered Mar 8 at 10:18
Matt NorrieMatt Norrie
39610
39610
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056776%2fhow-to-use-canvas-setleft-on-datetime-in-wpf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown