Last active
December 8, 2017 00:40
-
-
Save kaitlynbrown/6e1fb254794431a3b739d7618e3442b2 to your computer and use it in GitHub Desktop.
StackOverFlow post with error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On a page where I am displaying a receipt to a user, I have a section which lists the subtotal, any taxes, and the total. Since the taxes applicable vary by region and based on the products being sold, the number of rows in this section will vary. For example, here are 3 separate orders, one with GST and PST, one with just GST, and one with neither: | |
[![GST+PST][1]][1] | |
[![GST Only][2]][2] | |
[![No Tax][3]][3] | |
I've accomplished this by putting just the SubTotal in the grid in XAML, and adding the rest in the code-behind in a method I call from the ViewModel. However, I'd really like to avoid doing it this way, so I'm wondering if there is an approach to accomplishing this which doesn't require having a bunch of code in the View's code-behind and having the ViewModel know about the View. | |
A ListView is not suitable here for a number of reasons: | |
- These controls are inside of a scrollview, and having a listview inside of a scrollview causes all sorts of weird problems. | |
- I would like to keep the columns as narrow as their widest element. This is possible with a Grid, but a ListView would take up the entire width of its parent no matter what. | |
- I neither need nor want for my rows to be selectable | |
So is there a way I can do this entirely from the ViewModel without resorting to using a ListView? | |
[1]: https://i.stack.imgur.com/k7ypX.png | |
[2]: https://i.stack.imgur.com/hUOyi.png | |
[3]: https://i.stack.imgur.com/jEMYL.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On a page where I am displaying a receipt to a user, I have a section which lists the subtotal, any taxes, and the total. Since the taxes applicable vary by region and based on the products being sold, the number of rows in this section will vary. For example, here are 3 separate orders, one with GST and PST, one with just GST, and one with neither: | |
![GST+PST](https://i.stack.imgur.com/k7ypX.png) | |
![GST Only](https://i.stack.imgur.com/hUOyi.png) | |
![No Tax](https://i.stack.imgur.com/jEMYL.png) | |
I've accomplished this by putting just the SubTotal in the grid in XAML, and adding the rest in the code-behind in a method I call from the ViewModel. However, I'd really like to avoid doing it this way, so I'm wondering if there is an approach to accomplishing this which doesn't require having a bunch of code in the View's code-behind and having the ViewModel know about the View. | |
A ListView is not suitable here for a number of reasons: | |
- These controls are inside of a scrollview, and having a listview inside of a scrollview causes all sorts of weird problems. | |
- I would like to keep the columns as narrow as their widest element. This is possible with a Grid, but a ListView would take up the entire width of its parent no matter what. | |
- I neither need nor want for my rows to be selectable | |
So is there a way I can do this entirely from the ViewModel without resorting to using a ListView? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On a page where I am displaying a receipt to a user, I have a section which lists the subtotal, any taxes, and the total. Since the taxes applicable vary by region and based on the products being sold, the number of rows in this section will vary. For example, here are 3 separate orders, one with GST and PST, one with just GST, and one with neither: | |
![GST+PST](https://i.stack.imgur.com/k7ypX.png) | |
![GST Only](https://i.stack.imgur.com/hUOyi.png) | |
![No Tax](https://i.stack.imgur.com/jEMYL.png) | |
I've accomplished this by putting just the SubTotal in the grid in XAML, and adding the rest in the code-behind in a method I call from the ViewModel. However, I'd really like to avoid doing it this way, so I'm wondering if there is an approach to accomplishing this which doesn't require having a bunch of code in the View's code-behind and having the ViewModel know about the View. | |
A `ListView` is not suitable here for a number of reasons: | |
- These controls are inside of a `ScrollView`, and having a `ListView` inside of a `ScrollView` causes all sorts of weird problems. | |
- I would like to keep the columns as narrow as their widest element. This is possible with a `Grid`, but a `ListView` would take up the entire width of its parent no matter what. | |
- I neither need nor want for my rows to be selectable | |
So is there a way I can do this entirely from the ViewModel without resorting to using a `ListView`? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On a page where I am displaying a receipt to a user, I have a section which lists the subtotal, any taxes, and the total. Since the taxes applicable vary by region and based on the products being sold, the number of rows in this section will vary. For example, here are 3 separate orders, one with GST and PST, one with just GST, and one with neither: | |
<img src="https://i.stack.imgur.com/k7ypX.png"> | |
<img src="https://i.stack.imgur.com/hUOyi.png"> | |
<img src="https://i.stack.imgur.com/jEMYL.png"> | |
I've accomplished this by putting just the SubTotal in the grid in XAML, and adding the rest in the code-behind in a method I call from the ViewModel. However, I'd really like to avoid doing it this way, so I'm wondering if there is an approach to accomplishing this which doesn't require having a bunch of code in the View's code-behind and having the ViewModel know about the View. | |
A `ListView` is not suitable here for a number of reasons: | |
- These controls are inside of a `ScrollView`, and having a `ListView` inside of a `ScrollView` causes all sorts of weird problems. | |
- I would like to keep the columns as narrow as their widest element. This is possible with a `Grid`, but a `ListView` would take up the entire width of its parent no matter what. | |
- I neither need nor want for my rows to be selectable | |
So is there a way I can do this entirely from the ViewModel without resorting to using a `ListView`? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On a page where I am displaying a receipt to a user, I have a section which lists the subtotal, any taxes, and the total. Since the taxes applicable vary by region and based on the products being sold, the number of rows in this section will vary. For example, here are 3 separate orders, one with GST and PST, one with just GST, and one with neither: | |
![GST+PST](https://i.stack.imgur.com/k7ypX.png) | |
![GST Only](https://i.stack.imgur.com/hUOyi.png) | |
![No Tax](https://i.stack.imgur.com/jEMYL.png) | |
I've accomplished this by putting just the SubTotal in the grid in XAML, and adding the rest in the code-behind in a method I call from the ViewModel. However, I'd really like to avoid doing it this way, so I'm wondering if there is an approach to accomplishing this which doesn't require having a bunch of code in the View's code-behind and having the ViewModel know about the View. | |
A `ListView` is not suitable here for a number of reasons: | |
- These controls are inside of a `ScrollView`, and having a `ListView` inside of a `ScrollView` causes all sorts of weird problems. | |
- I would like to keep the columns as narrow as their widest element. This is possible with a `Grid`, but a `ListView` would take up the entire width of its parent no matter what. | |
- I neither need nor want for my rows to be selectable | |
So is there a way I can do this entirely from the ViewModel without resorting to using a `ListView`? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment