473,382 Members | 1,376 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Custom Panel

Hello,

I'm trying to create a custom panel in WPF, which would act like a
WrapPanel but with a "NewLine" option. So I'm trying to create kinda
"StackPanel" which would host WrapPanels.

Tutorials on custom Panels over the internet talk a lot about creating
a new Panel from scratch, overriding MeasureOverride and
ArrangeOverride. However, all that i want to do is to "route" any new
UIElement to the current row's WrapPanel.

The goal is, finally, to display this as:
<myPanel>
<Item1>
<Item2>
<NewLine>
<Item3>
</myPanel>

which would be internally stored as:
<StackPanel>
<WrapPanel>
<Item1>
<Item2>
</WrapPanel>
<WrapPanel>
<Item3>
</WrapPanel>
</StackPanel>

I can't figure out how to do. I tried to override ArrangeOverride but
have problems with Child and visual tree. Is there an easy way to do
this ?

Thanks in advance...
Jun 27 '08 #1
1 1822
"Vivien Parlat" <po****@gmail.comwrote in message
news:0a**********************************@d45g2000 hsc.googlegroups.com...
Hello,

I'm trying to create a custom panel in WPF, which would act like a
WrapPanel but with a "NewLine" option. So I'm trying to create kinda
"StackPanel" which would host WrapPanels.

Tutorials on custom Panels over the internet talk a lot about creating
a new Panel from scratch, overriding MeasureOverride and
ArrangeOverride. However, all that i want to do is to "route" any new
UIElement to the current row's WrapPanel.

The goal is, finally, to display this as:
<myPanel>
<Item1>
<Item2>
<NewLine>
<Item3>
</myPanel>

which would be internally stored as:
<StackPanel>
<WrapPanel>
<Item1>
<Item2>
</WrapPanel>
<WrapPanel>
<Item3>
</WrapPanel>
</StackPanel>

I can't figure out how to do. I tried to override ArrangeOverride but
have problems with Child and visual tree. Is there an easy way to do
this ?
Just an idea - why not derive your panel from WrapPanel and define an
attached property such as MyPanel.NewLineAfter? Then you could take the
existing WrapPanel MesaureOverride and ArrangeOverride methods (using
Reflector to get them) and adapt them to take account of children with
NewLineAfter set to True. This might be simpler than having to mess about
with changing the children of your control. The XAML would then look like:
<myPanel>
<Item1>
<Item2 MyPanel.NewLineAfter=True">
<Item3>
</myPanel>

Chris Jobson
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
2
by: Novice | last post by:
I can't seem to get my Custom WebControl to output a button whose click event is associated with a particular method. Here is the code I have right now that contains a panel and there is a...
1
by: Chris Newby | last post by:
I have a custom control that derives from the WebControls.Panel class. In a given ASPX document, I have an instance of my custom control with ID set to "MyControl". Then I put a...
2
by: topdawg147 | last post by:
I'm trying to build a custom control that includes a panel control on it. However, in design-time when I drag a new control (e.g. a textbox, etc) into the panel, it's not added in the panel--just...
3
by: Charles Zhang | last post by:
I want to create a simple server control that does thing like: <Mc:CollapsibleControl TitlePanelID="panel1" BodyPanelID="Panel2"> <asp:Panel ID="panel1"> ... </asp:Panel> <asp:Panel...
0
by: Walter | last post by:
Hi, can someone please help me with my custom control viewstate problem....I haven't slept for hours trying to get this fixed. I am making two custom controls which will be included on a single...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
2
by: Olorin | last post by:
I'm encountering some weird behavior with the ClientID property. Let's see if I can give you enough info and if anyone has ideas/suggestions. I'm working in ASP.NET 2.0. I have a Web Project with...
4
by: Jimmy | last post by:
hi, all I'm having a problem with creating custom events in wxpython. I have a class A handling some data processing work and another class B of GUI matter. I need GUI to display information...
2
tranc3d
by: tranc3d | last post by:
Hello, I have a custom panel in my project (this one: http://www.codeproject.com/KB/graphics/fastimagedrawing.aspx) with a custom paint event ( protected override void OnPaint(PaintEventArgs pe)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.