Silverlight 3 TabItem Positioning Error - silverlight-3.0

07-06-2011 4:34 AM | LINK
Hi,
We are facing a problem in Silverlight 3 with the placement of TabItem in the TabControl. We have a maximum of 9 tabs to be displayed. But the problem is that for different user profiles, the number of tabs may decrease i.e. we collapse the not required tabs accordingly. This creates a change in the way the tabs are displayed.
Below is a sample code to represent the same scenario:
<UserControl x:Class="TabControlTrial.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" >
<Grid x:Name="LayoutRoot">
<Controls:TabControl Name="tbATReportMainMenu" TabStripPlacement="Top" Margin="5" Visibility="Visible">
<Controls:TabItem Name="A" Header="XXXX XXXXX XXXXXX XXXXXX"
Visibility="Visible">
</Controls:TabItem>
<Controls:TabItem Name="B" Header="XXXXXXXXXXX XXXXXXXX XXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="C" Header="XXXXXXXXXXX XXXXXXX X XXXXXXXXXXX XXXXXXXX XXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="D" Header="XXXXXXXXXXX XXXXXXX X XXXXXXX XXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="E" Header="XXXXXXXXXXX XXXXXXXX XXXXXXXXXXXX XXXXXXXX XXXXXXX XXXXXX"
Visibility=" Visible " >
</Controls:TabItem>
<Controls:TabItem Name="F" Header="XXXXXXXXXXXX XXXXXX XXXXXX X XXXXXXX XXXXXXX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="G" Header="XXXXXXXX XXXXXX"
Visibility=" Visible " >
</Controls:TabItem>
<Controls:TabItem Name="H" Header="XXXXXXXX XX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="I" Header="XXXXXX XXXXXX XXX XXXX XX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
</Controls:TabControl>
</Grid>
Output when all Tabs are set to visible.
Output when Tab E and G are collapsed.
As it can be seen from the screenshot above the Tabs get distorted in the alignment.
We have tried using all the Alignment properties for the TabItems and TabControl, but it is of no use.
Also note that the alignment can change based on screen resolutions.
Is there a way that this problem can be sorted?
Thanks in advance.

The above problem can be solved if we add TabItems dynamically through xaml.cs rather than showing/hiding the TabItems.

Related

Coloured log output is not reflecting in log4j 2 after providing in xml

i have configured the below xml to get the coloured output in console, but still not getting the coloured o/p
<PatternLayout pattern="%highlight{%d %-5p [%t] (%F:%L) - %m%n}{FATAL=red,ERROR=red, WARN=yellow bold, INFO=red, DEBUG=green bold, TRACE=blue}"/>

Xamarin Android project fails to build, with same errors over and over

This app has been built and run many times, including many times today, yesterday, etc.
Now, suddenly there are errors with the axml which hasn't changed i a while: One error is supposedly in activity_mail.axml. Most of the time at line 114 but sometimes at line 117.
Either those lines are blank or they contain perfectly valid axml.
Even if I add lines before 114 (or 117), the error is still at 114 or 117 or 113.
The axml is a Linear Layout, with a table layout followed by 8 table rows with contain EditViews, TextViews and Buttons. Much of the time it builds with no problem.
This is axml that (1) hasn't been changed in a while and (2) previous, like earlier today, compiled just fine and ran on my phone just fine.
BUT now I find these groups inserted into the axml (I've watched it happen):
<TextView
android:minWidth="30px"
android:minHeight="30px"
xmlns="http://schemas.android.com/apk/res/android"
android:id="#+id/textView4" />
<TextView
android:minWidth="30px"
android:minHeight="30px"
xmlns="http://schemas.android.com/apk/res/android"
android:id="#+id/textView5" />
<TextView
android:minWidth="30px"
android:minHeight="30px"
xmlns="http://schemas.android.com/apk/res/android"
android:id="#+id/textView6" />
When it happens, there are 5 or 6 groups of them. Always the same. Mostly in groups of 3 and the width and height are always 30px. At the end of the axml sometimes there is one of these one or two lines long. Today this happened over and over.
Today was by far the worst. Each time I rebuild the app, the build fails as these groups are inserted into the axml. Six times today so far.
I've tried deleting the bin and obj folders the Resource.Designer.cs file, but that didn't help.
I'm using VS 2019 (Community) Version 16.3.9 on Windows 10 Enterprise.
I can't make the axml read only as that (for no reason I can understand) causes the build to fail.
I have rebooted my computer, but that changed nothing.
in your axml,each element should contains width and height properties,so you try to change your axml like below :
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="30px"
android:minHeight="30px"
android:id="#+id/textView4" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="30px"
android:minHeight="30px"
android:id="#+id/textView5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="30px"
android:minHeight="30px"
android:id="#+id/textView6" />

SVG Vector Effect

I am trying to define a fixed stroke width into my SVG, similar to this thread.
In my devenv (VS 2017) I am running Edge and the project is targeting .net 4.6.1
The SVG is defined as:
<svg version="1.1"
baseProfile="full"
width="100%" height="Auto"
viewBox="0 0 #sheet.SheetShape.Bounds.Width #sheet.SheetShape.Bounds.Height"
xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" stroke="red" fill="white" />
#foreach (var cut in sheet.SheetCuts)
{
<line vector-effect="non-scaling-stroke" stroke-width="2" stroke="black" stroke-dasharray="5, 5" x1=#cut.Start.X y1=#cut.Start.Y x2=#cut.End.X y2=#cut.End.Y />
}
The vector-effect property is not recognized by VS intellisense and when the code runs nothing special happens.
What should be wrong?

the display result of tiled map is wrong (using cocos2d-x 3.6)

this is what I created in my TiledMap Editor:
But when I try to display it in simulator, it becomes this:
You can see some of tile images are missed, some are wrong(the place where dirt.png should be become wall.png instead). I don't know why this happened. I follow the tutorial and add the following code in the HelloWorld project.
// create a TMX map
auto map = TMXTiledMap::create("tile/test.tmx");
addChild(map);
the content of test.tmx:
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="36" tileheight="36" nextobjectid="5">
<tileset firstgid="1" name="test" tilewidth="36" tileheight="36">
<tile id="0">
<image width="36" height="36" source="dirt.png"/>
</tile>
<tile id="1">
<image width="36" height="36" source="floor.png"/>
</tile>
<tile id="2">
<image width="36" height="36" source="wall.png"/>
</tile>
</tileset>
<layer name="Tile Layer 1" width="10" height="10">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAA2NkYGBgRMMwgM7GhRnQaEJmMaCJ4zILXS8+dbjsxOY+XO4g5FZ0M0GAiQBGV49PDwgAAKCoyOyQAQAA
</data>
</layer>
<objectgroup name="Object Layer 1">
<object id="1" name="SpawnPoint" x="125" y="133" width="67" height="62"/>
</objectgroup>
</map>
Could any one give me a hand?
okay... I have found why....
There are limitations which cocos2d-x support Tied Map Editor.
in this page, http://www.cocos2d-x.org/wiki/TileMap, it says:
Tiles:
- Embedded tiles are NOT supported (i.e., tilesets with embedded images).
- Only embedded tilesets are supported (i.e., the tileset is embedded, but not its images).
- supports at most 1 tileset per layer.
So.... each of tilesets MUST only contain one image.
And... each of layer MUST only contain one tilesets.
If you don't follow the rule while editing map in the Tied Map Editor. The result will become chaos like mine.

Ruby's Truncate unsanitizes MS Word code

Curious if anyone ever noticed this, but I have a WYSIWYG that users occassionally paste from word into. There is a word sanitizer, but not everyone's a genius.
If I parse that text somewhere else, it comes out right. But if I truncate it, then the msword code appears.
Does anyone know why truncate unsanitizes this || does anyone know how to sanitize and truncate at the same time?
UPDATE:
Here's an example of the msword being displayed after I truncate :
&Lt;! [If Gte Mso 9]>&Lt;Xml> &Lt;Br /> &Lt;O:Office Document Settings> &Lt;Br /> &Lt;O:Allow Png/> &Lt;Br /> &Lt;/O:Office Document Settings> &Lt;Br />&Lt;/Xml>&Lt;![Endif] >&Lt;! [If Gte Mso 9]>&Lt;Xml> &Lt;Br /> &Lt;W:Word Document> &Lt;Br /> &Lt;W:Zoom>0&Lt;/W:Zoom> &Lt;Br /> &Lt;W:Track Moves>False&Lt;/W:Track Moves> &Lt;Br /> &Lt;W:Track Formatting/> &Lt;Br /> &Lt;W:Punctuation Kerning/> &Lt;Br /> &Lt;W:Drawing Grid Horizontal Spacing>18 Pt&Lt;/W:Drawing Grid Horizontal Spacing> &Lt;Br /> &Lt;W:Drawing Grid Vertical Spacing>18 Pt&Lt;/W:Drawing Grid Vertical Spacing> &Lt;Br /> &Lt;W:Display Horizontal Drawing Grid Every>0&Lt;/W:Display Horizontal Drawing Grid Every> &Lt;Br /> &Lt;W:Display Vertical Drawing Grid Every>0&Lt;/W:Display Vertical Drawing Grid Every> &Lt;Br /> &Lt;W:Validate Against Schemas/> &Lt;Br /> &Lt;W:Save If Xml Invalid>False&Lt;/W:Save If Xml Invalid> &Lt;Br /> &Lt;W:Ignore Mixed Content>False&Lt;/W:Ignore Mixed Content> &Lt;Br /> &Lt;W:Always Show Placeholder Text>False&Lt;/W:Always Show Placeholder Text> &Lt;Br /> &Lt;W:Compatibility> &Lt;Br /> &Lt;W:Break Wrapped Tables/> &Lt;Br /> &Lt;W:Dont Grow Autofit/> &Lt;Br /> &Lt;W:Dont Autofit Constrained Tables/> &Lt;Br /> &Lt;W:Dont Vert Align In Txbx/> &Lt;Br /> &Lt;/W:Compatibility> &Lt;Br /> &Lt;/W:Word Document> &Lt;Br />&Lt;/Xml>&Lt;![Endif] >&Lt;! [If Gte Mso 9]>&Lt;Xml> &Lt;Br /> &Lt;W:Latent Styles Def Locked State="False" Latent Style Count="276"> &Lt;Br /> &Lt;/W:Latent Styles> &Lt;Br />&Lt;/Xml>&Lt;![Endif] > &Lt;! {Cke Protected}%3 C!%2 D%2 D%7 Bcke Protected%7 D%253 C!%252 D%252 D%257 Bcke Protected%257 D%25253 C!%25252 D%25252 D%25257 Bcke Protected%25257 D%2525253 C!%2525252 D%2525252 D%2525257 Bcke Protected%2525257 D%252525253 C!%252525252 D%252525252 D%252525257 Bcke Protected%252525257 D%25252525253 C!%25252525252 D%25252525252 D%25252525257 Bcke Protected%25252525257 D%2525252525253 C!%2525252525252 D%2525252525252 D%2525252525250 A%25252525252520%2525252525252 F*%25252525252520 Font%25252525252520 Definitions%25252525252520*%2525252525252 F%2525252525250 A%25252525252540font Face%2525252525250 A%25252525252509%2525252525257 Bfont Family%2525252525253 A Times%2525252525253 B%2525252525250 A%25252525252509panose 1%2525252525253 A2%252525252525200%252525252525205%252525252525200%252525252525200%252525252525200%252525252525200%252525252525200%252525252525200%252525252525200%2525252525253 B%2525252525250 A%25252525252509mso Font Charset%2525252525253 A0%2525252525253 B%2525252525250 A%25252525252509mso Generic Font Family%2525252525253 Aauto%2525252525253 B%2525252525250 A%25252525252509mso Font Pitch%2525252525253 Avariable%2525252525253 B%2525252525250 A%25252525252509mso Font Signature%2525252525253 A3%252525252525200%252525252525200%252525252525200%252525252525201%252525252525200%2525252525253 B%2525252525257 D%2525252525250 A%25252525252540font Face%2525252525250 A%25252525252509%2525252525257 Bfont Family%2525252525253 A Verdana%2525252525253 B%2525252525250 A%25252525252509panose 1%2525252525253 A2%2525252525252011%252525252525206%252525252525204%25
The whole thing is about 600 characters long. This is the first 200 or so :
“Excellent” – The New York Times
“4 Stars” - The Star-Ledger
“Best Romantic Restaurant” – Suburban Essex
“Best View” – OpenTable
In December 1986, the Knowles opened Highlawn after months of restoration to the former open-air “casino” which had, along with the now-prosperous park, been neglected for several years.
Here's a custom sanitizer I made with the help of Stackoverflow :
def sanitized_text(text)
sanitized = text.gsub(/&Lt;[^>]*>/, '')
end
The trouble with this sanitizer is that it returns empty white space after I truncate to 125 characters. I expanded it to 600 characters, and I get a single line that is another msword conditional statement.
Update:
This is the code that produces the msword content.
= truncate(organization.about_us, 125)
Note that when I just put this :
= organization.about_us
It comes out fine, but of course not truncated.
I should also add this is Ruby 1.8.7 / rails 2.3.5
Truncating HTML is always a real hassle because you can end up splitting tags and entities. Without proper UTF-8 handling, you also run the risk of chopping a two byte character in half.
Another thing to watch out for is overly greedy regular expressions:
def sanitized_text(text)
sanitized = text.gsub(/&Lt;[^>]*?>/, '')
end
The *? will capture the minimum that matches, where * will capture the largest match.
For instance:
<A><B>
This can be grouped into "<", "A><B", and ">" if you end up with the wrong expression.
Edit: I've tried to reproduce this and had no luck.
With this example, using your text pasted in and sanitized, everything appears to be okay.
# app/controllers/example_controller.rb
class ExampleController < ApplicationController
def index
#text = '&Lt;! [If Gte Mso 9]>&Lt;Xml> &Lt;Br /> &Lt;O:Office Document Settings> &Lt;Br /> &Lt;O:Allow Png/> &Lt;Br /> &Lt;/O:Office Document Settings> &Lt;Br />&Lt;/Xml>&Lt;![Endif] >&Lt;! [If Gte Mso 9]>&Lt;Xml> &Lt;Br /> &Lt;W:Word Document> &Lt;Br /> &Lt;W:Zoom>0&Lt;/W:Zoom> &Lt;Br /> &Lt;W:Track Moves>False&Lt;/W:Track Moves> &Lt;Br /> &Lt;W:Track Formatting/> &Lt;Br /> &Lt;W:Punctuation Kerning/> &Lt;Br /> &Lt;W:Drawing Grid Horizontal Spacing>18 Pt&Lt;/W:Drawing Grid Horizontal Spacing> &Lt;Br /> &Lt;W:Drawing Grid Vertical Spacing>18 Pt&Lt;/W:Drawing Grid Vertical Spacing> &Lt;Br /> &Lt;W:Display Horizontal Drawing Grid Every>0&Lt;/W:Display Horizontal Drawing Grid Every> &Lt;Br /> &Lt;W:Display Vertical Drawing Grid Every>0&Lt;/W:Display Vertical Drawing Grid Every> &Lt;Br /> &Lt;W:Validate Against Schemas/> &Lt;Br /> &Lt;W:Save If Xml Invalid>False&Lt;/W:Save If Xml Invalid> &Lt;Br /> &Lt;W:Ignore Mixed Content>False&Lt;/W:Ignore Mixed Content> &Lt;Br /> &Lt;W:Always Show Placeholder Text>False&Lt;/W:Always Show Placeholder Text> &Lt;Br /> &Lt;W:Compatibility> &Lt;Br /> &Lt;W:Break Wrapped Tables/> &Lt;Br /> &Lt;W:Dont Grow Autofit/> &Lt;Br /> &Lt;W:Dont Autofit Constrained Tables/> &Lt;Br /> &Lt;W:Dont Vert Align In Txbx/> &Lt;Br /> &Lt;/W:Compatibility> &Lt;Br /> &Lt;/W:Word Document> &Lt;Br />&Lt;/Xml>&Lt;![Endif] >&Lt;! [If Gte Mso 9]>&Lt;Xml> &Lt;Br /> &Lt;W:Latent Styles Def Locked State="False" Latent Style Count="276"> &Lt;Br /> &Lt;/W:Latent Styles> &Lt;Br />&Lt;/Xml>&Lt;![Endif] > &Lt;! {Cke Protected}%3 C!%2 D%2 D%7 Bcke Protected%7 D%253 C!%252 D%252 D%257 Bcke Protected%257 D%25253 C!%25252 D%25252 D%25257 Bcke Protected%25257 D%2525253 C!%2525252 D%2525252 D%2525257 Bcke Protected%2525257 D%252525253 C!%252525252 D%252525252 D%252525257 Bcke Protected%252525257 D%25252525253 C!%25252525252 D%25252525252 D%25252525257 Bcke Protected%25252525257 D%2525252525253 C!%2525252525252 D%2525252525252 D%2525252525250 A%25252525252520%2525252525252 F*%25252525252520 Font%25252525252520 Definitions%25252525252520*%2525252525252 F%2525252525250 A%25252525252540font Face%2525252525250 A%25252525252509%2525252525257 Bfont Family%2525252525253 A Times%2525252525253 B%2525252525250 A%25252525252509panose 1%2525252525253 A2%252525252525200%252525252525205%252525252525200%252525252525200%252525252525200%252525252525200%252525252525200%252525252525200%252525252525200%2525252525253 B%2525252525250 A%25252525252509mso Font Charset%2525252525253 A0%2525252525253 B%2525252525250 A%25252525252509mso Generic Font Family%2525252525253 Aauto%2525252525253 B%2525252525250 A%25252525252509mso Font Pitch%2525252525253 Avariable%2525252525253 B%2525252525250 A%25252525252509mso Font Signature%2525252525253 A3%252525252525200%252525252525200%252525252525200%252525252525201%252525252525200%2525252525253 B%2525252525257 D%2525252525250 A%25252525252540font Face%2525252525250 A%25252525252509%2525252525257 Bfont Family%2525252525253 A Verdana%2525252525253 B%2525252525250 A%25252525252509panose 1%2525252525253 A2%2525252525252011%252525252525206%252525252525204%2'
end
end
# app/helpers/example_helper.rb
module ExampleHelper
def sanitized_text(text)
text.gsub(/&Lt;[^>]*>/, '')
end
end
The view itself is pretty much what you have:
<!-- app/views/example/index.html.erb -->
<body>
<strong>Original</strong>
<div>
<%= sanitized_text(#text) %>
</div>
<strong>Truncated</strong>
<div>
<%= truncate(sanitized_text(#text), :length => 125) %>
</div>
<strong>Truncated With Deprecated Option</strong>
<div>
<%= truncate(sanitized_text(#text), 125) %>
</div>
</body>
This was on OS X with Ruby 1.8.7p174, Rails 2.3.5 using WEBrick to test.

Resources