Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
255
How to Bind Group Template Properties
posted

Hi all, I want to know how to bind the properties IsEnabled and Visibilty from the xaml in the outlookbar, for each element like : 

             <igOB:XamWebOutlookBar.GroupHeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Header}" />
                </DataTemplate>
            </igOB:XamWebOutlookBar.GroupHeaderTemplate>

 or something like : <Setter Property="IsEnabled"> and there put some template for each group ...

Any help will be appreciated...

Paul.

Parents
  • 3071
    Verified Answer
    posted

    Hi Paul,
    Look at this small sample.
    DataItem class represents some external data. I added the Enabled and Visible properties to keep everything simple, but you may need to use converters.
    C#
    public class DataItem
    {
      public bool Enabled { get; set; }
      public Visibility Visible { get; set; }
      public string Name { get; set; }
    }
    private void xob_Loaded(object sender, RoutedEventArgs e)
    {
      ObservableCollection<DataItem> c = new ObservableCollection<DataItem>();
      c.Add(
    new DataItem { Name = "A", Enabled = true, Visible = Visibility.Visible });
      c.Add(
    new DataItem { Name = "B", Enabled = false, Visible = Visibility.Visible });
      c.Add(
    new DataItem { Name = "C", Enabled = true, Visible = Visibility.Collapsed });
      c.Add(
    new DataItem { Name = "D", Enabled = false, Visible = Visibility.Collapsed });
      xob.GroupsSource = c;
    }
    XAML 
    <igOB:XamWebOutlookBar x:Name="xob" Grid.Column="1" Loaded="xob_Loaded"> 
      <igOB:XamWebOutlookBar.GroupHeaderTemplate>
        <DataTemplate>
          <StackPanel Orientation="Horizontal">
           <TextBlock Text="{Binding Name}"/>
          </StackPanel>
        </DataTemplate>
      </igOB:XamWebOutlookBar.GroupHeaderTemplate>
      <igOB:XamWebOutlookBar.GroupContentTemplate>
        <DataTemplate>
          <StackPanel>
            <TextBlock Text="{Binding Name}"/>
            <TextBlock Text="{Binding Enabled}"/>
            <TextBlock Text="{Binding Visible}"/>
          </StackPanel>
        </DataTemplate>
      </igOB:XamWebOutlookBar.GroupContentTemplate>
      <igOB:XamWebOutlookBar.DefaultGroupsContainer>
        <DataTemplate>
          <igOB:OutlookBarGroup IsEnabled="{Binding Enabled}" Visibility="{Binding Visible}"/>
        </DataTemplate>
      </igOB:XamWebOutlookBar.DefaultGroupsContainer>
    </
    igOB:XamWebOutlookBar>
    Regards,
    Marin

Reply Children
No Data