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

TimeSpanUpDown ShowDays and ShowSeconds bug inside ListView.ItemTemplate #1768

Open
tqk2811 opened this issue Jan 25, 2024 · 3 comments
Open

Comments

@tqk2811
Copy link

tqk2811 commented Jan 25, 2024

Version: Extended.Wpf.Toolkit 4.6.0 ( latest )

<!--top TimeSpanUpDown-->
 <Xceed:TimeSpanUpDown Value="{Binding Source={StaticResource TimeRange},Path=TimeRange}" ShowDays="False" ShowSeconds="False"/>

<!--List View-->
<ListView MinHeight="60" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
          ItemsSource="{Binding Source={StaticResource TimeRange},Path=TimeList}" 
          d:ItemsSource="{d:SampleData ItemCount=10}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ListView.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsChecked}" VerticalAlignment="Center"/>
                <Xceed:TimeSpanUpDown Value="{Binding Time}" Maximum="23:59" Minimum="00:00"/>
            </StackPanel>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

image

When i change TimeSpanUpDown inside listview such as

<Xceed:TimeSpanUpDown Value="{Binding Time}" ShowDays="False"/>
<Xceed:TimeSpanUpDown Value="{Binding Time}" ShowSeconds="False"/>
<Xceed:TimeSpanUpDown Value="{Binding Time}" ShowDays="False" ShowHours="False"/>

No error msg in output visual studio

image

@tqk2811 tqk2811 changed the title TimeSpanUpDown not work in ListView.ItemTemplate TimeSpanUpDown not work in DataTemplate Jan 25, 2024
@tqk2811 tqk2811 changed the title TimeSpanUpDown not work in DataTemplate TimeSpanUpDown ShowDays and ShowSeconds bug Jan 25, 2024
@tqk2811 tqk2811 changed the title TimeSpanUpDown ShowDays and ShowSeconds bug TimeSpanUpDown ShowDays and ShowSeconds bug inside ListView.ItemTemplate Jan 25, 2024
@XceedBoucherS
Copy link
Collaborator

Hello,

I've created a basic sample based on yours :

image

public MainWindow()
{
InitializeComponent();

this.DataContext = new List()
{
new TimeSpan(9, 11, 32),
new TimeSpan(21, 5, 14),
};
}

It is working as expected with the latest v4.6 version of the Toolkit on NuGet:
image

I'm I missing something or it's in your sample ?
Thank you

@tqk2811
Copy link
Author

tqk2811 commented Jan 29, 2024

image

<Window x:Class="WpfTestXceedTimeSpanUpDown.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfTestXceedTimeSpanUpDown"
        xmlns:Xceed="http://schemas.xceed.com/wpf/xaml/toolkit"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Window.DataContext>
        <local:MainWVM/>
    </Window.DataContext>
    <Grid>
        <!--<Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>-->
        <StackPanel Orientation="Vertical" >
            <!--(1)-->
            <Xceed:TimeSpanUpDown Grid.Row="0" Value="{Binding Path=TimeSpan}" ShowSeconds="False"/>

            <ListView Grid.Row="1" ItemsSource="{Binding TimeList}" >
                <ListView.View>
                    <GridView>
                        <GridViewColumn Width="300">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <!--(2)-->
                                    <Xceed:TimeSpanUpDown Value="{Binding Time}" ShowDays="False"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
                <!--<ListView.ItemTemplate>
                    <DataTemplate>
                        --><!--(3)--><!--
                        <Xceed:TimeSpanUpDown Value="{Binding Time}" ShowSeconds="False"/>
                    </DataTemplate>
                </ListView.ItemTemplate>-->
            </ListView>
        </StackPanel>
    </Grid>
</Window>
internal class MainWVM
{
    public TimeSpan TimeSpan { get; set; } = TimeSpan.FromHours(2);
    public ObservableCollection<TimeVM> TimeList { get; } = new ObservableCollection<TimeVM>()
    {
        new TimeVM(),
        new TimeVM(),
        new TimeVM(),
        new TimeVM(),
        new TimeVM(),
        new TimeVM(),
        new TimeVM(),
    };
}
public class TimeVM
{
    public TimeSpan Time { get; set; } = TimeSpan.FromHours(1);
}

https://github.com/tqk2811/WpfTestXceedTimeSpanUpDown

(1) work
(2) (3) failed (may be problem because inside DataTemplate)


Update:

  • net462: work
  • net6.0-windows: failed
  • net7.0-windows: failed

@XceedBoucherS
Copy link
Collaborator

Hi,

Thank you for the feedback.
I was able to reproduce the issue. It will be fixed in the next release.

If you want a quick fix, you can go in file
Xceed.Wpf.Toolkit/TimeSpanUpDown/Implementation/TimeSpanUpDown.cs
and replace all the occurences of
this.Value = something
to
this.SetCurrentValue( TimeSpanUpDown.ValueProperty, something);

Thank you

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