Ajout du bouton#26
Ajout du bouton#26andre726 wants to merge 4 commits intouwp-squad:masterfrom andre726:Buttonchatbranch
Conversation
|
|
||
| namespace Livecoding.UWP.ViewModels | ||
| { | ||
| class ChatList : ListViewItem |
There was a problem hiding this comment.
Pourquoi cette classe ? Si elle ne fait rien de précis, elle ne doit pas exister. De plus, si c'est pour gérer l'affichage d'une ListView pour le chat, tu peux le faire sans difficulté dans la View et le ViewModel.
There was a problem hiding this comment.
c'est dans quelle fichier que je dois gérer l'affichage de la liste?
There was a problem hiding this comment.
Tu dois modifier 2 fichiers principalement : la StreamPage et le StreamViewModel. En gros, la vue et la logique de la vue.
Dans le ViewModel, il faut par exemple que tu ajoutes la propriété suivante :
private bool _showChat;
public bool ShowChat
{
get { return _showChat; }
set { _showChat = value; RaisePropertyChanged(); }
}
Et après dans la vue, tu fais le binding.
| </DataTemplate> | ||
| </lvcontrols:LivecodingMediaTransportControls.HeaderTemplate> | ||
| </lvcontrols:LivecodingMediaTransportControls> | ||
| <AppBarButton x:Name="ChatButton" |
There was a problem hiding this comment.
Il me semble que cet AppBarButton doit être intégré au contrôle LivecodingMediaTransportControls. Normalement, le template de ce contrôle est dans App.xaml.cs.
| Icon="Contact" | ||
| Style="{StaticResource AppBarButtonStyle}" | ||
| MediaTransportControlsHelper.DropoutOrder="5" | ||
| VerticalAlignment="Center" |
There was a problem hiding this comment.
Il manque la balise de fermeture />
| </MediaPlayerElement> | ||
| <ListViewItem x:Name="ChatList" IsEnabled="False" Visibility="Collapsed"/> | ||
|
|
||
| </MediaPlayerElement.TransportControls> |
|
|
||
| </MediaPlayerElement.TransportControls> | ||
|
|
||
| </MediaPlayerElement> |
| </MediaPlayerElement.TransportControls> | ||
|
|
||
| </MediaPlayerElement> | ||
| <ListViewItem x:Name="ChatList" IsEnabled="False" Visibility="Collapsed"/> |
There was a problem hiding this comment.
A déplacer en dehors du contrôle MediaPlayerElement.
| </MediaPlayerElement.TransportControls> | ||
|
|
||
| </MediaPlayerElement> | ||
| <ListViewItem x:Name="ChatList" IsEnabled="False" Visibility="Collapsed"/> |
There was a problem hiding this comment.
Je te conseille d'utiliser le contrôle ListView plutôt que ListViewItem Et aussi, pourquoi utiliser la propriété IsEnabled, la propriété Visibility est amplement suffisante.
| </MediaPlayerElement> | ||
|
|
||
| </Grid> | ||
| <ListView x:Name="ChatList" Visibility="Collapsed" /> |
| </MediaPlayerElement> | ||
|
|
||
| </Grid> | ||
| <ListView x:Name="ChatList" Visibility="Collapsed" /> |
There was a problem hiding this comment.
Pour mettre à jour le fait qu'elle soit visible : Visibility={Binding Path=ShowChat}
| DataContext="{Binding ShowChat, Source = {StaticRessource Locator}}" | ||
| MediaTransportControlsHelper.DropoutOrder="5" | ||
| VerticalAlignment="Center" | ||
| Onclick="ChatHide_Show"> |
There was a problem hiding this comment.
Inutile de mettre un event OnClick, il faudra passer par une Command.
There was a problem hiding this comment.
quelle est la différence?
There was a problem hiding this comment.
Si tu passes par des events comme OnClick par exemple, tu vas devoir gérer la logique dans le code-behind, ce qui est à éviter dans 99% des cas.
Si tu passes par une Command, tu vas pouvoir manipuler la logique dans le ViewModel. Tu peux prendre exemple sur ce ViewModel https://github.com/uwp-squad/livecoding-uwp/blob/master/LIvecoding-uwp/Livecoding/ViewModels/LivestreamsViewModel.cs#L50
There was a problem hiding this comment.
Le bouton devrait se situer à proximité des autres boutons ici https://github.com/uwp-squad/livecoding-uwp/blob/master/LIvecoding-uwp/Livecoding/App.xaml#L728
There was a problem hiding this comment.
Et dans l'immédiat, tu peux faire un binding direct sur la commande de ton ViewModel pour voir ce que ça donne. Je vois pas d'autre solution simple pour le moment.
| <DataTemplate> | ||
| <usercontrols:StreamHeaderControl DataContext="{Binding Stream, Source={StaticResource Locator}}" /> | ||
|
|
||
| <controls:AppBarButton x:Name="ChatButton" |
There was a problem hiding this comment.
Idem que la fois précédente, à placer dans App.xaml.cs
There was a problem hiding this comment.
mais c'est du xaml ici, pas du c#
There was a problem hiding this comment.
Je me suis trompé, c'est dans App.xaml. Dans le DataTemplate du control.
There was a problem hiding this comment.
ok, je vais chercher pour voir ou le mettre :)
| <controls:AppBarButton x:Name="ChatButton" | ||
| Icon="Contact" | ||
| Style="{StaticResource AppBarButtonStyle}" | ||
| DataContext="{Binding ShowChat, Source = {StaticRessource Locator}}" |
|
|
||
| #region Properties | ||
| private ListView _chatlist; | ||
| public ListView ChatList |
There was a problem hiding this comment.
A remplacer par public ObservableCollection<ChatMessage> Messages { get; } = new ObservableCollection<ChatMessage>();
dispositions des element dans appxaml, depuis bcp d'erreur
| </Storyboard> | ||
| </VisualState> | ||
| </VisualStateGroup> | ||
|
|
There was a problem hiding this comment.
Suppression de la ligne en trop
| </AppBarButton.Icon> | ||
| </AppBarButton> | ||
| <AppBarButton x:Name="ChatButton" | ||
|
|
There was a problem hiding this comment.
Suppression de la ligne en trop
| <AppBarButton x:Name="ChatButton" | ||
|
|
||
| MediaTransportControlsHelper.DropoutOrder ="5" | ||
| Visibility="Collapsed" |
There was a problem hiding this comment.
Le bouton est censé être toujours visible, non ? Ligne à supprimer.
|
|
||
| MediaTransportControlsHelper.DropoutOrder ="5" | ||
| Visibility="Collapsed" | ||
| Command="ChatVisibilityChange"> |
There was a problem hiding this comment.
Voilà comment on écrit une commande généralement :
Command="{Binding ShowChatCommand}"
There was a problem hiding this comment.
Dans notre cas, je pense plutôt qu'il faut l'appeler ToggleChatCommand.
| <FontIcon Glyph="comment"/> | ||
| </AppBarButton.Icon> | ||
| </AppBarButton> | ||
|
|
There was a problem hiding this comment.
Suppression des lignes en trop
| <lvcontrols:LivecodingMediaTransportControls.HeaderTemplate> | ||
| <DataTemplate> | ||
| <usercontrols:StreamHeaderControl DataContext="{Binding Stream, Source={StaticResource Locator}}" /> | ||
|
|
There was a problem hiding this comment.
Suppression des lignes en trop
| </DataTemplate> | ||
| </lvcontrols:LivecodingMediaTransportControls.HeaderTemplate> | ||
| </lvcontrols:LivecodingMediaTransportControls> | ||
|
|
There was a problem hiding this comment.
Suppression des lignes en trop
|
|
||
| </MediaPlayerElement.TransportControls> | ||
|
|
||
|
|
There was a problem hiding this comment.
Suppression des lignes en trop
| </MediaPlayerElement> | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Suppression des lignes en trop
| Visibility="Collapsed" | ||
| Command="ChatVisibilityChange"> | ||
| <AppBarButton.Icon> | ||
| <FontIcon Glyph="comment"/> |
There was a problem hiding this comment.
Il me semble qu'il y a une majuscule pour le nom d'une glyph. Donc ce serait Comment plutôt.
|
Pour ce qui est de la commande, il faudra la créer dans le ViewModel. Regarde des exemples si cela peut t'aider. Comme par ici : https://github.com/uwp-squad/livecoding-uwp/blob/master/LIvecoding-uwp/Livecoding/ViewModels/LivestreamsViewModel.cs#L37 |
No description provided.