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
Why not use SQL instead of GraphQL?
How do I create uniquely male characters?
Problem of parity - Can we draw a closed path made up of 20 line segments...
How to find program name(s) of an installed package?
To string or not to string
Is it unprofessional to ask if a job posting on GlassDoor is real?
How to write a macro that is braces sensitive?
Smoothness of finite-dimensional functional calculus
Why Is Death Allowed In the Matrix?
Is it possible to do 50 km distance without any previous training?
Why do falling prices hurt debtors?
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
What typically incentivizes a professor to change jobs to a lower ranking university?
What would happen to a modern skyscraper if it rains micro blackholes?
What defenses are there against being summoned by the Gate spell?
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
How can I make my BBEG immortal short of making them a Lich or Vampire?
"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"
Risk of getting Chronic Wasting Disease (CWD) in the United States?
Theorem, big Paralist and Amsart
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
How to format long polynomial?
How is it possible to have an ability score that is less than 3?
Today is the Center
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
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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
1,024725
1,024725
asked Mar 8 at 4:34
masterinexmasterinex
1672411
1672411
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,74284470
5,74284470
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
43111
43111
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