Code Monkey home page Code Monkey logo

Comments (4)

timunie avatar timunie commented on June 12, 2024

Hi @ExLuzZziVo

Thank you for posting this 🙏 . I am transferring this control to MahApps (see MahApps/MahApps.Metro#4006 ) and will address this issue there.

I think for now you should be able to overcome this by using a custom SelectedItemTemplate

Here is the original:

<!--#region DataTemplates-->
<DataTemplate x:Key="Tims.DataTemplates.MultiSelectionComboBox.Removeable">
<Grid>
<Border Margin="2"
Background="{DynamicResource MahApps.Brushes.Gray8}"
CornerRadius="{Binding RelativeSource={RelativeSource Mode=Self}, Path=ActualHeight, Converter={StaticResource MahApps.Converters.SizeToCornerRadius}}"
IsHitTestVisible="False" />
<StackPanel Margin="7,2,2,2" Orientation="Horizontal">
<ContentControl Margin="0"
VerticalAlignment="Center"
Content="{Binding}"
IsHitTestVisible="False" />
<Button Width="10"
Height="10"
Margin="5,2,2,2"
VerticalAlignment="Center"
mah:ControlsHelper.CornerRadius="5"
Command="ctrls:MultiSelectionComboBox.RemoveItemCommand"
CommandParameter="{Binding}"
IsHitTestVisible="True">
<Button.Style>
<Style BasedOn="{StaticResource MahApps.Styles.Button.Chromeless}" TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Accent2}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Highlight}" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
<Path Data="M10,1.6c-4.639,0-8.4,3.761-8.4,8.4c0,4.639,3.761,8.4,8.4,8.4s8.4-3.761,8.4-8.4C18.4,5.361,14.639,1.6,10,1.6z M14.789,13.061l-1.729,1.729L10,11.729l-3.061,3.06l-1.729-1.729L8.272,10L5.211,6.939L6.94,5.211L10,8.271l3.061-3.061 l1.729,1.729L11.728,10L14.789,13.061z"
Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
Stretch="Uniform" />
</Button>
</StackPanel>
</Grid>
</DataTemplate>

Happy coding and a happy new year
Tim

from timswpfcontrols.

ExLuzZziVo avatar ExLuzZziVo commented on June 12, 2024

I have found a solution. In GetSelectedItemsText method of MultiSelectionComboBox.cs I have used this code and it works:

            IEnumerable<object> values;

            if (ReadLocalValue(DisplayMemberPathProperty) != DependencyProperty.UnsetValue && !string.IsNullOrEmpty(DisplayMemberPath))
            {
                values = ((IEnumerable<object>)SelectedItems)?.Select(o => BindingHelper.Eval(o, DisplayMemberPath ?? string.Empty));
            }
            else
            {
                values = (IEnumerable<object>)SelectedItems;
            }

            if (values != null && ReadLocalValue(ItemStringFormatProperty) != DependencyProperty.UnsetValue &&
                !string.IsNullOrEmpty(ItemStringFormat))
            {
                values = values.Select(o => string.Format(ItemStringFormat, o));
            }

Happy holidays!

from timswpfcontrols.

timunie avatar timunie commented on June 12, 2024

@ExLuzZziVo thank you for providing your solution. I think I found an even better way, but it will not be implemented here. It will be available in MahApps soon (no due date right now).

Happy new year and happy coding
Tim

from timswpfcontrols.

ExLuzZziVo avatar ExLuzZziVo commented on June 12, 2024

@timunie Thank you. I will close the issue

from timswpfcontrols.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.