-1
  1. I Have a Textblock in a grid column which have different values like 2,4,1,0,3 etc.
  2. The values shows the quantity of students who belong to a play group activity as Cricket,BaseBall,Chess, BasketBall,Carrom etc.
  3. On Mouse Over a ToolTip is shown.This Tooltip conatins The name of Student who will play in the Specific Group

PlayGroup.xaml File

 <TextBlock TextAlignment="Center" VerticalAlignment="Center" Text="{Binding Path=RowData.Row.PlayGroup}" ToolTipService.ToolTip="{Binding Converter={StaticResource TooltipView}}"/>
 <UserControl.Resources>
<innercontrols:ListToStringConverter x:Key="TooltipView"/>
  </UserControl.Resources>

PlayGroup.CS File

public class ListToStringConverter : IValueConverter //List To String Converter
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                List<string> lst = new List<string>();
                string combindedString = "";
                try
                {
                    lst.Clear();
                    lst.Add("Cricket");
                    lst.Add("BaseBall");
                    lst.Add("Chess");
                    combindedString = string.Join("\n", lst.ToArray());
                    return combindedString;
                }
                catch (Exception ex)
                {

                } return combindedString;
            }
            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                return value; // throw new NotImplementedException();
            }
        }
  1. How can I bind Dynamic List as Tooltip based on the number of Students? Should I use String Builder or List or Observable Collection?
  2. In the above I have given a list of 3 students ,but we require to show dynamic data as list .
TechBrkTru
  • 346
  • 1
  • 25
  • How are the names supposed to be supplied? Is there another view model property? Your converter needs some kind of input. This is usually the value of a binding source property, which is passed to the value argument of the Convert method. – Clemens Apr 24 '18 at 07:03
  • The Input will be the count , accordingly on mouse hover the play group activity will be displayed .. @Clemens – TechBrkTru Apr 30 '18 at 09:48
  • @Clemens Input will be only count eg 2. – TechBrkTru Apr 30 '18 at 09:50

1 Answers1

-1

There must be a property in your model where "PlayGroup" is defined. Bind that property with the tooltip of the textblock. Once you do that the "value" parameter in your ListToStringConverter will have the list of names you passed to the converter. Use it to create the combindedString.

Shivani Katukota
  • 859
  • 9
  • 16