Encapsulating dynamic mouse UI element in WPF appliation
up vote
1
down vote
favorite
I am developing a C# WPF application utilizing MVVM pattern
In my app user via mouse (or touchscreen) sets offset values for the Pan-Tilt Motor. Since movement should be somwhat percise, I decided to create a UI helper element, which currently looks like this:
I want it to look nice and dandy, so that values wont be obscured or intersected with other lines:
But at the same time I want to stick to MVVM pattern, and such behaviour, although not hard to implement per se, requires a lot of bindings, logic and triggers. That clutters my XAML and View Model a lot, so here comes my question:
What is the common way/best practice of encapsulating such element (which is basically a complex dynamic figure) into some abstract form, hiding all irrelevant to the main app logic within it?
The desired solution wold look something like this:
<canvas>
<i:Interaction.Triggers>
<!--MouseUp, MouseDown, MouseMove Commands...-->
</i:Interaction.Triggers>
<i:Interaction.Behaviors>
<!--Getting Mouse X and Y values...-->
</i:Interaction.Behaviors>
<MouseUI MouseUiClass="{Binding MouseUiClass}"/>
or
<MouseUI Start="{Binding MouseUiClass.Start}"
End="{Binding MouseUiClass.End}"
IsFinished="{Binding MouseUiClass.IsFinished}"/>
</canvas>
I did consider to use UserControl
but I struggle to understand how to properly display it because dynamically resizes, and start and end point can be placed in any part of canvas.
c# wpf user-interface mvvm
New contributor
add a comment |
up vote
1
down vote
favorite
I am developing a C# WPF application utilizing MVVM pattern
In my app user via mouse (or touchscreen) sets offset values for the Pan-Tilt Motor. Since movement should be somwhat percise, I decided to create a UI helper element, which currently looks like this:
I want it to look nice and dandy, so that values wont be obscured or intersected with other lines:
But at the same time I want to stick to MVVM pattern, and such behaviour, although not hard to implement per se, requires a lot of bindings, logic and triggers. That clutters my XAML and View Model a lot, so here comes my question:
What is the common way/best practice of encapsulating such element (which is basically a complex dynamic figure) into some abstract form, hiding all irrelevant to the main app logic within it?
The desired solution wold look something like this:
<canvas>
<i:Interaction.Triggers>
<!--MouseUp, MouseDown, MouseMove Commands...-->
</i:Interaction.Triggers>
<i:Interaction.Behaviors>
<!--Getting Mouse X and Y values...-->
</i:Interaction.Behaviors>
<MouseUI MouseUiClass="{Binding MouseUiClass}"/>
or
<MouseUI Start="{Binding MouseUiClass.Start}"
End="{Binding MouseUiClass.End}"
IsFinished="{Binding MouseUiClass.IsFinished}"/>
</canvas>
I did consider to use UserControl
but I struggle to understand how to properly display it because dynamically resizes, and start and end point can be placed in any part of canvas.
c# wpf user-interface mvvm
New contributor
2
UserControl
is a good way to encapsulate the UI-related XAML and code in one place. I would do the positioning of the labels in code-behind. It doesn't break MVVM because it's purely UI-related code.
– dymanoid
yesterday
Honestly I would just draw that text with a thick white outline so the lines don't affect readability. Other than that, as for encapsulating this logic, if you like XAML then UserControl, if you prefer C# then a custom behavior or attached property (though I prefer behaviors).
– bokibeg
yesterday
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am developing a C# WPF application utilizing MVVM pattern
In my app user via mouse (or touchscreen) sets offset values for the Pan-Tilt Motor. Since movement should be somwhat percise, I decided to create a UI helper element, which currently looks like this:
I want it to look nice and dandy, so that values wont be obscured or intersected with other lines:
But at the same time I want to stick to MVVM pattern, and such behaviour, although not hard to implement per se, requires a lot of bindings, logic and triggers. That clutters my XAML and View Model a lot, so here comes my question:
What is the common way/best practice of encapsulating such element (which is basically a complex dynamic figure) into some abstract form, hiding all irrelevant to the main app logic within it?
The desired solution wold look something like this:
<canvas>
<i:Interaction.Triggers>
<!--MouseUp, MouseDown, MouseMove Commands...-->
</i:Interaction.Triggers>
<i:Interaction.Behaviors>
<!--Getting Mouse X and Y values...-->
</i:Interaction.Behaviors>
<MouseUI MouseUiClass="{Binding MouseUiClass}"/>
or
<MouseUI Start="{Binding MouseUiClass.Start}"
End="{Binding MouseUiClass.End}"
IsFinished="{Binding MouseUiClass.IsFinished}"/>
</canvas>
I did consider to use UserControl
but I struggle to understand how to properly display it because dynamically resizes, and start and end point can be placed in any part of canvas.
c# wpf user-interface mvvm
New contributor
I am developing a C# WPF application utilizing MVVM pattern
In my app user via mouse (or touchscreen) sets offset values for the Pan-Tilt Motor. Since movement should be somwhat percise, I decided to create a UI helper element, which currently looks like this:
I want it to look nice and dandy, so that values wont be obscured or intersected with other lines:
But at the same time I want to stick to MVVM pattern, and such behaviour, although not hard to implement per se, requires a lot of bindings, logic and triggers. That clutters my XAML and View Model a lot, so here comes my question:
What is the common way/best practice of encapsulating such element (which is basically a complex dynamic figure) into some abstract form, hiding all irrelevant to the main app logic within it?
The desired solution wold look something like this:
<canvas>
<i:Interaction.Triggers>
<!--MouseUp, MouseDown, MouseMove Commands...-->
</i:Interaction.Triggers>
<i:Interaction.Behaviors>
<!--Getting Mouse X and Y values...-->
</i:Interaction.Behaviors>
<MouseUI MouseUiClass="{Binding MouseUiClass}"/>
or
<MouseUI Start="{Binding MouseUiClass.Start}"
End="{Binding MouseUiClass.End}"
IsFinished="{Binding MouseUiClass.IsFinished}"/>
</canvas>
I did consider to use UserControl
but I struggle to understand how to properly display it because dynamically resizes, and start and end point can be placed in any part of canvas.
c# wpf user-interface mvvm
c# wpf user-interface mvvm
New contributor
New contributor
edited yesterday
New contributor
asked yesterday
Александр Теплов
63
63
New contributor
New contributor
2
UserControl
is a good way to encapsulate the UI-related XAML and code in one place. I would do the positioning of the labels in code-behind. It doesn't break MVVM because it's purely UI-related code.
– dymanoid
yesterday
Honestly I would just draw that text with a thick white outline so the lines don't affect readability. Other than that, as for encapsulating this logic, if you like XAML then UserControl, if you prefer C# then a custom behavior or attached property (though I prefer behaviors).
– bokibeg
yesterday
add a comment |
2
UserControl
is a good way to encapsulate the UI-related XAML and code in one place. I would do the positioning of the labels in code-behind. It doesn't break MVVM because it's purely UI-related code.
– dymanoid
yesterday
Honestly I would just draw that text with a thick white outline so the lines don't affect readability. Other than that, as for encapsulating this logic, if you like XAML then UserControl, if you prefer C# then a custom behavior or attached property (though I prefer behaviors).
– bokibeg
yesterday
2
2
UserControl
is a good way to encapsulate the UI-related XAML and code in one place. I would do the positioning of the labels in code-behind. It doesn't break MVVM because it's purely UI-related code.– dymanoid
yesterday
UserControl
is a good way to encapsulate the UI-related XAML and code in one place. I would do the positioning of the labels in code-behind. It doesn't break MVVM because it's purely UI-related code.– dymanoid
yesterday
Honestly I would just draw that text with a thick white outline so the lines don't affect readability. Other than that, as for encapsulating this logic, if you like XAML then UserControl, if you prefer C# then a custom behavior or attached property (though I prefer behaviors).
– bokibeg
yesterday
Honestly I would just draw that text with a thick white outline so the lines don't affect readability. Other than that, as for encapsulating this logic, if you like XAML then UserControl, if you prefer C# then a custom behavior or attached property (though I prefer behaviors).
– bokibeg
yesterday
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Александр Теплов is a new contributor. Be nice, and check out our Code of Conduct.
Александр Теплов is a new contributor. Be nice, and check out our Code of Conduct.
Александр Теплов is a new contributor. Be nice, and check out our Code of Conduct.
Александр Теплов is a new contributor. Be nice, and check out our Code of Conduct.
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%2f53372571%2fencapsulating-dynamic-mouse-ui-element-in-wpf-appliation%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
2
UserControl
is a good way to encapsulate the UI-related XAML and code in one place. I would do the positioning of the labels in code-behind. It doesn't break MVVM because it's purely UI-related code.– dymanoid
yesterday
Honestly I would just draw that text with a thick white outline so the lines don't affect readability. Other than that, as for encapsulating this logic, if you like XAML then UserControl, if you prefer C# then a custom behavior or attached property (though I prefer behaviors).
– bokibeg
yesterday