Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made PART_Track optional for Slider #14974

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

TomEdwardsEnscape
Copy link
Contributor

This part was made required in #14180, and this causes a build error in our product when using 11.1.0-beta1. This PR reverts the changes and also ensures that the _track field is not accessed when no track exists in the control template.

Our use case is that we have specialised slider controls, the templates of which do not contain tracks. One contains a nested slider (plus various other controls), and it is this nested slider which has a track and handles input. The other does not contain a track at all, and we handle all input ourselves.

There is also a workaround for this issue. Add the following XAML to the offending template:

<Track Name="PART_Track" IsVisible="False"/>

What is the current behavior?

Avalonia error AVLN2205: Required template part with x:Name 'PART_Track' must be defined on 'SemiCircularSlider' ControlTemplate.

Breaking changes

None

Obsoletions / Deprecations

None

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0046184-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@timunie
Copy link
Contributor

timunie commented Mar 14, 2024

Hi @TomEdwardsEnscape I can't wrap my head around the usecase here. Could you file a scetch of what you want to achieve?

Thank you

@TomEdwardsEnscape
Copy link
Contributor Author

Greatly simplified XAML:

<ControlTemplate TargetType="SettingSlider">
	<Grid>
		<Label Content="{TemplateBinding Header}"/>
		<Button Command="Reset" />
		<NumericUpDown x:Name="PART_TextInput" />
		<Slider Name="PART_Slider" />
	</Grid>
</ControlTemplate>

We then bind the properties of PART_Slider when the template is applied. This includes value converters for things like logarithmic value ranges.

In the second use case, the template contains nothing but text and a canvas on which we draw various paths and ellipses. Everything else is done in C# in response to mouse events.

Both cases are part of our control library. We want the controls to be sliders and inherit all of that type's public properties.

@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 14, 2024
@maxkatz6 maxkatz6 added the backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch label Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 14, 2024
@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 15, 2024
Merged via the queue into AvaloniaUI:master with commit 1911955 Mar 15, 2024
6 checks passed
@TomEdwardsEnscape TomEdwardsEnscape deleted the fixes/slider-optional-track branch March 15, 2024 09:13
maxkatz6 pushed a commit that referenced this pull request Apr 6, 2024
@maxkatz6 maxkatz6 added backported-11.1.x and removed backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants