private void Action_Click(object sender, EventArgs e) { ChatImageCardDataItem dataItem = this.DataItem as ChatImageCardDataItem; LightVisualElement lightVisualElement = sender as LightVisualElement; foreach (ChatCardAction action in dataItem.Actions) { if (action.Text == lightVisualElement.Text) { this.OnCardActionClicked(new CardActionEventArgs(action, this.DataItem.UserData)); } } }
protected override void Synchronise() { base.Synchronise(); ChatImageCardDataItem dataItem = this.DataItem as ChatImageCardDataItem; this.ImageElement.Image = dataItem.Image; this.TitleElement.Text = dataItem.Title; this.SubtitleElement.Text = dataItem.Subtitle; this.TextElement.Text = dataItem.Text; while (this.StackElement.Children.Count > 4) { this.StackElement.Children.RemoveAt(4); } if (dataItem.Actions == null) { return; } foreach (ChatCardAction action in dataItem.Actions) { LightVisualElement lightVisualElement = new LightVisualElement(); lightVisualElement.Text = action.Text; lightVisualElement.Padding = new Padding(0, 8, 0, 8); lightVisualElement.TextAlignment = ContentAlignment.MiddleCenter; lightVisualElement.BorderBoxStyle = BorderBoxStyle.FourBorders; lightVisualElement.BorderTopColor = Color.Gray; lightVisualElement.BorderTopShadowColor = Color.Gray; lightVisualElement.BorderTopWidth = 2f; lightVisualElement.BorderLeftWidth = 0.0f; lightVisualElement.BorderRightWidth = 0.0f; lightVisualElement.BorderBottomWidth = 0.0f; lightVisualElement.DrawBorder = true; lightVisualElement.SmoothingMode = SmoothingMode.AntiAlias; lightVisualElement.Click += new EventHandler(this.Action_Click); this.StackElement.Children.Add((RadElement)lightVisualElement); } }
public ChatImageCardElement(ChatImageCardDataItem item) : base((BaseChatCardDataItem)item) { }