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
875
How to set ContentTemplateMinimizedExpanded in code-behind
posted

Most of my tiles are set up via the XAML, as follows:

<igTiles:Tile x:Name="PrimaryTile"

        Header="Primary Library">

   <igTiles:Tile.ContentTemplateMinimizedExpanded>

      <DataTemplate x:Name="PriMinExp">

         <local:PrimaryWpfUsrCtrlThumb/>

      </DataTemplate>

   </igTiles:Tile.ContentTemplateMinimizedExpanded>

</igTiles:Tile>

What is the equivalent for a tile that I need to create in code-behind.  So far, I have:

myTile=new Tile();

myTile.Header="My Tile";

But how do I set the ContentTemplateMinimizedExpanded for this?  Basically I am just wanting different content (in this case a user control) in whenthe state is minimized expanded.   While I'm at it, how do i set MinimizedExpanded Tile Constraints (ex-MaxHeight) in code behind.  I tried:

myTile.ConstraintsMinimizedExpanded.MaxHeight=150 to no avail

 

 

Parents
No Data
Reply
  • 54937
    Verified Answer
    Offline posted

    .

    treehan said:
    But how do I set the ContentTemplateMinimizedExpanded for this?
    Creating a DataTemplate in code (for our properties or those in the wpf framework) means creating a FrameworkElementFactory and building the VisualTree in code.
    DataTemplate dt = new DataTemplate();
    var fef = new FrameworkElementFactory(typeof(UserControl));
    dt.VisualTree = fef;

    treehan said:
    While I'm at it, how do i set MinimizedExpanded Tile Constraints (ex-MaxHeight) in code behind.  I tried:

    myTile.ConstraintsMinimizedExpanded.MaxHeight=150 to no avail

    Constraints(Minimized|Maximized|MinimizedExpanded) are properties on Tile so you would create an instance of the TileConstraints class, set properties on it and then set the relevant Constraints property to that. E.g.
    Tile tile = new Tile();
    TileConstraints tc = new TileConstraints();
    tc.MaxHeight = 150;
    tile.Constraints = tc;

     

Children
No Data