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

Style for ComboBox breaks HorizontalContentAlignment #5

Closed
nkristek opened this issue May 27, 2018 · 2 comments
Closed

Style for ComboBox breaks HorizontalContentAlignment #5

nkristek opened this issue May 27, 2018 · 2 comments

Comments

@nkristek
Copy link
Collaborator

Setting HorizontalContentAlignment has no effect when the style is active. Adding an empty style like the following fixes the problem, so its definitely caused by the custom style:

<ComboBox ItemsSource="{Binding ComboBoxItems}"
    HorizontalContentAlignment="Stretch">

    <!-- this removes the style but fixes the problem -->
    <ComboBox.Style>
        <Style>

        </Style>
    </ComboBox.Style>

    <ComboBox.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <!-- Text on the left edge -->
                <TextBlock Grid.Column="0" 
                    Text="Left edge"/>

                <!-- Text on the right edge -->
                <TextBlock Grid.Column="3"
                    Text="Right edge"/>
            </Grid>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>
@nkristek nkristek changed the title Style for ComboBox overrides HorizontalContentAlignment Style for ComboBox breaks HorizontalContentAlignment May 27, 2018
@nkristek
Copy link
Collaborator Author

nkristek commented Jun 6, 2018

An issue still persists after f6c107e.
The HorizontalContentAligment now applies but with the given example, the content stretches over the full width of the combobox and under the arrow on the right side of the control. Currently, the fix would be:

<ComboBox ItemsSource="{Binding ComboBoxItems}"
    HorizontalContentAlignment="Stretch">

    <ComboBox.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="12"/> <!-- this line fixes the problem -->
                </Grid.ColumnDefinitions>

                <!-- Text on the left edge -->
                <TextBlock Grid.Column="0" 
                    Text="Left edge"/>

                <!-- Text on the right edge -->
                <TextBlock Grid.Column="3"
                    Text="Right edge"/>
            </Grid>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

The problem with this fix is, that in the unfolded state this margin is present too

@nkristek nkristek reopened this Jun 6, 2018
benruehl added a commit that referenced this issue Jun 10, 2018
…ates (#5) and text selection on editable comboboxes
@benruehl
Copy link
Owner

First fix seemed to work for editable ComboBoxes only, sorry for that.
The fix for non-editable ones is out now.

nkristek added a commit to nkristek/Stein that referenced this issue Jun 21, 2018
- update AdonisUI and remove temporary fix for benruehl/adonis-ui#5
- update Smaragd
- add tooltip to button in the application toolbar
- remove unused style
- show local datetime instead of UTC
- show relative date if the date was recently
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants