|
ImageMessage ImageMessage;
ImageSource imageSource;
SfPopupLayout pop;
private void createMessage(Stream stream , EventArgs args)
{
byte[] imageBytes = ReadFully(stream);
imageSource = Xamarin.Forms.ImageSource.FromStream(() => new MemoryStream(imageBytes));
pop = new SfPopupLayout();
pop.PopupView.ShowHeader = false;
DataTemplate bodyTemplateView = new DataTemplate(() =>
{
var imageView = new Image();
imageView.BackgroundColor = Color.Black;
imageView.Source = imageSource;
imageView.Margin = new Thickness(0, 20, 0, 20);
return imageView;
});
DataTemplate footerTemplateView = new DataTemplate(() =>
{
StackLayout stack = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.EndAndExpand };
Button cancelButton = new Button();
cancelButton.BackgroundColor = Color.Transparent;
cancelButton.Text = "Cancel";
cancelButton.Clicked += CancelButton_Clicked;
Button oKButton = new Button();
oKButton.Text = "Send";
oKButton.BackgroundColor = Color.Transparent;
oKButton.Clicked += OKButton_Clicked;
stack.Children.Add(cancelButton);
stack.Children.Add(oKButton);
return stack;
});
pop.PopupView.ContentTemplate = bodyTemplateView;
pop.PopupView.FooterTemplate = footerTemplateView;
pop.ShowRelativeToView(Chat.Editor.Parent.Parent as View, RelativePosition.AlignTop, absoluteY: -5);
this.ViewModel.attachmentPopup.Dismiss();
}
private void OKButton_Clicked(object sender, EventArgs e)
{
ImageMessage = new ImageMessage();
ImageMessage.Aspect = Aspect.Fill;
ImageMessage.Source = imageSource;
ImageMessage.Author = this.ViewModel.CurrentUser;
this.ViewModel.Messages.Add(ImageMessage);
pop.IsOpen = false;
}
|



|
AttachmentPopupView popupTemplate = new AttachmentPopupView();
popupTemplate.ViewModel = this;
popupTemplate.Chat = args as SfChat;
attachmentPopup = new SfPopupLayout();
attachmentPopup.PopupView.ShowHeader = false;
attachmentPopup.PopupView.ShowFooter = false;
attachmentPopup.PopupView.AnimationMode = AnimationMode.Fade;
attachmentPopup.PopupView.PopupStyle.BorderThickness = 0;
attachmentPopup.PopupView.PopupStyle.CornerRadius = 45;
attachmentPopup.PopupView.WidthRequest = ((args as SfChat).Editor.Parent.Parent as View).Width;
attachmentPopup.PopupView.HeightRequest = 170;
DataTemplate bodyTemplateView = new DataTemplate(() =>
{
return popupTemplate;
});
attachmentPopup.PopupView.ContentTemplate = bodyTemplateView;
attachmentPopup.ShowRelativeToView((args as SfChat).Editor.Parent.Parent as View, RelativePosition.AlignTop, 0, -5); |

|
ChatView.LoadMoreCommand = viewModel.LoadMoreCommand;
var listview = (SfListView)ChatView.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("ChatListView")).GetValue(ChatView);
listview.FooterSize = 0;
FooterView footerView = (FooterView)(this.ChatView.Content as Grid).Children[1];
ContentView contentView = (ContentView)(footerView as Grid).Children[1];
var border = (contentView.Content as SfBorder);
border.CornerRadius = new Thickness(0);
|
|
var listview = (SfListView)sfChat.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("ChatListView")).GetValue(sfChat);
listview.FooterSize = 0;
FooterView footerView = (FooterView)(this.sfChat.Content as Grid).Children[1];
ContentView contentView = (ContentView)(footerView as Grid).Children[1];
var border = (contentView.Content as SfBorder);
((border.Content as Grid).Children[0] as Editor).BackgroundColor = Color.Red;
border.CornerRadius = new Thickness(0);
border.BorderColor = Color.Blue; |
|
<sfPopup:SfPopupLayout x:Name="Popup1" IsOpen="{Binding ShowPopupImage}" StaysOpen="{Binding ShowPopupImage}">
<sfPopup:SfPopupLayout.PopupView>
<sfPopup:PopupView AppearanceMode="TwoButton" ShowHeader="False">
<sfPopup:PopupView.ContentTemplate>
<DataTemplate>
<Image Source="{Binding ImageSourceBinding}" BackgroundColor="LightGray"/>
</DataTemplate>
</sfPopup:PopupView.ContentTemplate>
<sfPopup:PopupView.FooterTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand">
<buttons:SfButton Text="Remove" Command="{Binding RemoveImageSourceCommand}"/>
<buttons:SfButton Text="Hide" Command="{Binding HideImageCommand}"/>
</StackLayout>
</DataTemplate>
</sfPopup:PopupView.FooterTemplate>
</sfPopup:PopupView>
</sfPopup:SfPopupLayout.PopupView>
</sfPopup:SfPopupLayout>
… //Code behind Popup1.RelativeView = (sfChat.Editor.Parent.Parent as View); Popup1.AbsoluteX = 0;
Popup1.AbsoluteY = -5;
Popup1.RelativePosition = RelativePosition.AlignTop; |