maui
maui copied to clipboard
Net Maui on platform Windows PointerOver and Selected states is not working together ?
Description
Net Maui on platform Windows PointerOver and Selected states is not working together ? Also when I set first selection is selected ( MyCollectionview.SelectedItem = ((ObservableCollection)MyCollectionview.ItemsSource).FirstOrDefault(); ) selection is done but color of item disappear I think It is bug. .How to fix it ? Thanks
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.3
Affected platforms
Windows
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response
Could you please create a reproduceable sample showing what you wrote and how you implemented it? I'm not sure what you're trying to do based on what you wrote.
Hi @ssamix. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
xml....
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyDesktop.Controls.TabsFixed " x:Name="TabFixedView"> <CollectionView x:Name="TabsF" HorizontalScrollBarVisibility="Never" ItemsSource="{Binding Source={x:Reference TabFixedView}, Path=ItemsSource, Mode=OneWay}" SelectionMode="Single" VerticalScrollBarVisibility="Never"> <CollectionView.ItemsLayout> <GridItemsLayout Orientation="Vertical" Span="3" /> </CollectionView.ItemsLayout> <CollectionView.ItemTemplate> <DataTemplate> <Grid x:Name="tabGrid" Padding="15,3,15,0" BackgroundColor="{DynamicResource BackColor}" HeightRequest="36" HorizontalOptions="FillAndExpand"> <Label x:Name="tabLabel" FontSize="15" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text="{Binding TabTitle}" /> </Grid> </DataTemplate> </CollectionView.ItemTemplate> </CollectionView> </ContentView>
class.....
public partial class TabsFixed : ContentView { public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection<TabsItem>), typeof(TabsFixed), new ObservableCollection<TabsItem>()); public ObservableCollection<TabsItem> ItemsSource { get { return (ObservableCollection<TabsItem>)GetValue(ItemsSourceProperty); } set { SetValue(ItemsSourceProperty, value); } }
public TabsFixed()
{
InitializeComponent();
Content.BindingContext = this;
Setter backgroundColorSetter = new Setter() { Property = Grid.BackgroundColorProperty, Value = new Binding("MyColor") };
Setter textColorSetter = new Setter() { Property = Label.TextColorProperty, Value = Colors.White, TargetName = "tabLabel" };
VisualState stateNormal = new VisualState() { Name = CommonStates.Normal };
VisualState statePointOver = new VisualState() { Name = CommonStates.PointerOver, Setters = { backgroundColorSetter, textColorSetter } };
VisualState stateSelected = new VisualState() { Name = CommonStates.Selected, Setters = { backgroundColorSetter, textColorSetter } };
VisualStateGroup visualStateGroup = new VisualStateGroup() { Name = nameof(CommonStates), States = { stateNormal,stateSelected,statePointOver } };
VisualStateGroupList visualStateGroupList = new VisualStateGroupList() { visualStateGroup };
Setter vsgSetter = new Setter() { Property = VisualStateManager.VisualStateGroupsProperty, Value = visualStateGroupList };
Style style = new Style(typeof(Grid)) { Setters = { vsgSetter } };
Resources.Add(style);
Loaded += TabsFixed_Loaded;
}
private void TabsFixed_Loaded(object? sender, EventArgs e)
{
TabsF.SelectedItem = ((ObservableCollection<TabsItem>)TabsF.ItemsSource).FirstOrDefault();
}
}
contentPage.....
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyDesktop.Views.Mainpage" xmlns:control="clr-namespace:MyDesktop.Controls">
<Grid >
<control:TabsFixed ItemsSource="{Binding MainMenu}" HorizontalOptions="FillAndExpand" />
</Grid>
class...
public partial class Mainpage: ContenPage { public Mainpage() { InitializeComponent(); BindingContext= new MenuViewModel(); } }
menuviewmodel ....
public class MenuViewModel:ViewModelBase {
public ObservableCollection<TabsItem> _MainMenu = new ObservableCollection<TabsItem>();
public ObservableCollection<TabsItem> MainMenu
{
get
{
return _MainMenu ;
}
set
{
_MainMenu = value;
OnPropertyChanged("MainMenu ");
}
}
public MenuViewModel()
{
PopulateData();
}
void PopulateData()
{
MainMenu .Clear();
MainMenu .Add(new TabsItem() { TabTitle = "Shopping", BColor = "#339933" });
MainMenu .Add(new TabsItem() { TabTitle = "Food", BColor = "#FF0000" });
}
}
Hi @ssamix. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.