Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Table like control to set width in percentages

Table like control to set width in percentages

Scheduled Pinned Locked Moved WPF
csharpcsswpfdata-structurestutorial
3 Posts 2 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    djdajo
    wrote on last edited by
    #1

    Hi all, I'm fiddling around with WPF quite a bit, but i can't seem to get this working: I want four controls in a horizontal row (expanders in this case) to each have 1/4 (25%) of the width of the entire screen (so horizontally they fill up the whole screen, even when resizing..) But here's the catch, the expanders are filled with icons, so when i set width to auto, the expander gets the width depending on how many icons (images) are in the expander's content.. I tried using a grid with colums, but i didnt find out how to set the width to 25% of each column, is there ven a way to do this? Or does another control do what i want? Also tried a stack/wrappanel, but it didnt work out.. Thx

    A 1 Reply Last reply
    0
    • D djdajo

      Hi all, I'm fiddling around with WPF quite a bit, but i can't seem to get this working: I want four controls in a horizontal row (expanders in this case) to each have 1/4 (25%) of the width of the entire screen (so horizontally they fill up the whole screen, even when resizing..) But here's the catch, the expanders are filled with icons, so when i set width to auto, the expander gets the width depending on how many icons (images) are in the expander's content.. I tried using a grid with colums, but i didnt find out how to set the width to 25% of each column, is there ven a way to do this? Or does another control do what i want? Also tried a stack/wrappanel, but it didnt work out.. Thx

      A Offline
      A Offline
      artwallacex
      wrote on last edited by
      #2

      Would a UniformGrid work for you there?

      D 1 Reply Last reply
      0
      • A artwallacex

        Would a UniformGrid work for you there?

        D Offline
        D Offline
        djdajo
        wrote on last edited by
        #3

        I just read something about this, will see if it works, thx! /does exactly the same as a normal grid.. Example of what im doing: <grid> <expander content="{Staticresource somecontent}" /> <Expander content="{Staticresource somecontent2}" /> <Expander content="{Staticresource somecontent3}" /> <Expander content="{Staticresource somecontent4}"/> </grid> The resource content is something like this: ... Each expander resizes now to the amount of content (images) in them, which is different for each 1.. Found a solution: <Grid.ColumnDefinitions> <ColumnDefinition Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=2}, Path=ColumnDefinitions[0].Width}" /> <ColumnDefinition Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=2}, Path=ColumnDefinitions[1].Width}"/> <ColumnDefinition Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=2}, Path=ColumnDefinitions[2].Width}"/> <ColumnDefinition Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=2}, Path=ColumnDefinitions[3].Width}"/> </Grid.ColumnDefinitions>

        modified on Friday, April 11, 2008 3:48 AM

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups