Select to view content in your preferred language

Is it possible to set a controltemplate for a linesymbol?

1071
4
02-25-2014 02:13 AM
Labels (1)
ae
by
Frequent Contributor
Hi,

Is it somehow possible to specify a controltemplate for a LineSymbol? The reason I ask is that I want to change the appearance of the line depending on the value of a property on the viewmodel, so I need to use binding. I cannot use the uniquevaluerenderer, as it doesn't support bindings in the Field property.

Many thanks.
0 Kudos
4 Replies
AnttiKajanus1
Deactivated User
You should try to avoid using ContentTemplates to supporting AcceleratedDisplay and make it easier to move to next releases / new SDKs.

Can you provide a bit more information that you are hoping to do?
0 Kudos
AnttiKajanus1
Deactivated User
I would suggest one of the solutions:

1) Hook to PropertyChanged event in View codebehind and change renderer there manually. This is definitely the easiest and fastest way to implement this if you know what ViewModel the View has. Having a bit code in view is not issue since it is only related on the visualization that is views job anyway.

2) Use ViewService to provide functionality to ViewModel as service. If you go with this, you need to implement ie. IRendererService in View and then inject to ViewModel. Then you could use that in ViewModel like IRendererService.ChangeRendererToSomethingElse() without violating MVVM design. This solution isn't based on binding thou but should work quite nicely.

3) Create attached property that is bound to your property in ViewModel. Then construct (or fetch more likely) correct renderer for the layer from resources. For this you most likely would create also static class that has resource dictionary that contains renderers so you could easily use that from the attached property.

I would implement this most likely using first option. Thanks for the very interesting issue and use case. If you have any questions about the solutions I suggested, please let me know.
0 Kudos
ae
by
Frequent Contributor
I would suggest one of the solutions:

1) Hook to PropertyChanged event in View codebehind and change renderer there manually. This is definitely the easiest and fastest way to implement this if you know what ViewModel the View has. Having a bit code in view is not issue since it is only related on the visualization that is views job anyway.

2) Use ViewService to provide functionality to ViewModel as service. If you go with this, you need to implement ie. IRendererService in View and then inject to ViewModel. Then you could use that in ViewModel like IRendererService.ChangeRendererToSomethingElse() without violating MVVM design. This solution isn't based on binding thou but should work quite nicely.

3) Create attached property that is bound to your property in ViewModel. Then construct (or fetch more likely) correct renderer for the layer from resources. For this you most likely would create also static class that has resource dictionary that contains renderers so you could easily use that from the attached property.

I would implement this most likely using first option. Thanks for the very interesting issue and use case. If you have any questions about the solutions I suggested, please let me know.


Hi Antti, and many thanks for your reply!

I think the first suggestion would be the way to go, even though I would not like to use code-behind. Thanks!
0 Kudos
AnttiKajanus1
Deactivated User
Np, remember to mark question answered.
0 Kudos