In the following code, there is a column that gets displayed called
'All day event' for some reason here the 't' is getting cut off. can you point me if there is any value here too large that would cause this?
<dxe:CheckEdit x:Name="chkAllDay" Margin="0,6,202,4" Grid.Column="2"
Content="{Binding Source={StaticResource SchedulerControlStringIdConverter},
ConverterParameter=Form_AllDayEvent,
Converter={StaticResource SchedulerControlStringIdConverter}}"
EditValue="{Binding Controller.AllDay}" IsReadOnly="{Binding ReadOnly}"
IsEnabled="True" HorizontalAlignment="Right" Width="81" />
Your CheckEdit has its Width fixed to 81 pixels and also fixed Margins*. From your code snippet I cannot guess how the whole layout looks, but be sure to re-calculate those values. Maybe you've just accidentally got 5px off and the remaining area is too small for the text?
*) I said about Margin, but I've mistaken them with Padding. Margin is not relevant here, they it's the outer spacing' and does not count to the Width. OTOH, the Padding would. I think here's one good explanation
Related
So I have a TextBox with fixed height and width.
I want to have a slider or something else on the TextBox to make the missing text visible.
By missing text I mean the text that is longer than the width of the TextBox.
It doesn't have to be a slider just something that allows me to see the cut text.
I tried:
<TextBox ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto" />
but it does nothing for me.
Test this:
<TextBox ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Width="300"
Height="200"
TextWrapping="Wrap"
AcceptsReturn="True"
FontSize="22pt"
Text="Some loooooooooong text. Some loooooooooong text. Some long text. Some long text. Some long text. Some long text. Some long text. Some long text. "
/>
The key here is setting TextWrapping="Wrap". Also, if you want to be able to make a new line with the ENTER key, set AcceptsReturn="True".
If the scroll bar doesn't show for you, maybe your Width and Height isn't as "fixed" as you thought. The size of ScrollViewer needs to be limited somehow. Make sure that your TextBox is properly positioned in its container. For example, you may temporarily set its BorderThickness="5" and see if it isn't clipped anywhere (this may be the case if you have any HorizontalAlignment / VerticalAlignment other than Stretch).
EDIT:
As I mentioned, for scrolling a TextBox, all depends on the value of TextWrapping property.
For a TextBox, scrolling horizontally out-of-the-box only only makes sense if the text isn't wrapped (meaning there's only one very long line):
<TextBox ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
Width="300"
Height="200"
TextWrapping="NoWrap"
FontSize="22pt"
Text="Some loooooooooong text. Some loooooooooong text. Some long text. Some long text. Some long text. Some long text. Some long text. Some long text. "
/>
If you want to have more than one line of text to scroll it horizontally, you have to wrap a TextBox in a ScrollViewer explicitly and set the sizes correctly to limit the ScrollViewer's content:
<ScrollViewer
Width="200"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<TextBox Name="txb1"
Width="500"
VerticalAlignment="Stretch"
TextWrapping="Wrap"
AcceptsReturn="True"
FontSize="22pt"
Text="Some loooooooooong text. Some loooooooooong text. Some long text. Some long text. Some long text. Some long text. Some long text. Some long text. "
/>
</ScrollViewer>
I guess if you want to "auto-adjust" the width of the TextBox somehow, you'd need to calculate it as text changes. A way to do it off the top of my head (there are probably better solutions):
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
txb1.Width = txb1.Text.Split('\n').Max(a =>a.Length) * approximatedCharWidth;
}
where as approximatedCharWidth I used:
approximatedCharWidth = MeasureString(txb1, "lext").Width/4.0;
private Size MeasureString(TextBox textBlock, string candidate)
{
var formattedText = new FormattedText(
candidate,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(textBlock.FontFamily, textBlock.FontStyle, textBlock.FontWeight, textBlock.FontStretch),
textBlock.FontSize,
Brushes.Black,
new NumberSubstitution(),
1);
return new Size(formattedText.Width, formattedText.Height);
}
If you just have a plain string with no line feeds then this can only work for horizontal OR vertical scrolling.
If you can scroll horizontally then you're telling the text it can be as wide as it likes. Which means you will get one line.
If you instead wanted it to go across multiple lines then you either need linefeeds in the text or avoid any horizontal scrolling.
Seeing as you don't seem to want vertical scrolling I tried this:
<TextBox ScrollViewer.HorizontalScrollBarVisibility="Auto"
Text="ABCDEFGIJKLMNOPQRSTUVWXYZ ABCDEFGIJKLMNOPQRSTUVWXYZ ABCDEFGIJKLMNOPQRSTUVWXYZ ABCDEFGIJKLMNOPQRSTUVWXYZ"
Height="36"
Width="200"
/>
Which gives:
Which seems to be what you're after.
I'm developing a vision processing application using WPF and EmguCV 3.0. My issue is that the element isn't positioned correctly on-screen. I have viewed what the padding is, and it returns all sides as 0. The ImageBox element from Emgu, which is what I am using to display the images, is encapsulated in a Windows Forms Host control. I have two other ImageBox elements, which display properly. Each of the ImageBox elements are within their own tab in a TabControl. On startup, I set the width and height properties of all the ImageBoxes and their canvases.
An additional thing to note is that the other two ImageBoxes also overflow out of their boundaries, but are reset back into the boundaries after switching back and forth between the tabs. This only happens once.
Here is a link to screenshots of what the UI looks like. http://imgur.com/a/RwG17
Additionally, here is the XAML and C# code for the ImageBoxes.
<TabItem x:Name="ImageTabControlHSV">
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="HSV" />
</StackPanel>
</TabItem.Header>
<Canvas x:Name="HSVImageCanvas">
<WindowsFormsHost>
<emui:ImageBox x:Name="HSVImageBox"/>
</WindowsFormsHost>
</Canvas>
</TabItem>
//Width and height properties are gotten from camera image.
HSVImageBox.Width = ratioWidth;
HSVImageBox.Height = ratioHeight;
HSVImageCanvas.Width = width;
HSVImageCanvas.Height = height;
HSVImageCanvas.MaxHeight = height;
HSVImageCanvas.MaxWidth = width;
Any help or suggestions would be greatly appreciated.
UPDATE: Putting a counter for how many times the problematic ImageBox has been selected and using Canvas.SetTop() and Canvas.SetLeft() seems to be a workaround. I would still like to know why the canvas is changing its position.
You might try performing a Canvas.SetTop(HSVImageCanvas, HSVImageCanvas.Top) and Canvas.SetLeft(HSVImageCanvas, HSVImageCanvas.Left).
Doug
I resize the border according to timeline. Why when the Width becomes very big the Border disappear. For example for Width=100000 the Border is visible but for Width=200000 the Border disappears.
<StackPanel>
<Border BorderThickness="0,0,0,1" BorderBrush="Black" Height="100" Width="1000000">
</Border>
</StackPanel>
It turns out, that there are some limitations on the Border setting BorderThickness property.
Unfortunately, I can not say exactly how they look, I tried to find them using ILSpy (you can try to look for them am).
One limitation I can say: if the value of one coordinate over 125,000 the line of Border disappears. Here is my list of examples:
Thickness Width
--------- ---------
0,0,0,1 125 001
0,0,0,2 251 000
0,0,0,3 375 001
0,0,0,4 501 000
In all these cases, the line is not drawn.
As an alternative, you can increase the value for Thickness each time (not varinat), or using a Line / Separator, for them, there should be no restrictions. You need to change the value of Margin, depending on conditions or setting the Visibility for him.
Example with Separator:
<Separator Name="HighSignal"
Width="1000000"
Background="Black"
Height="2"
Visibility="Collapsed"
Margin="0,100,0,0" />
<Separator Name="LowSignal"
Width="1000000"
Background="Black"
Height="2"
Visibility="Visible"
Margin="0,0,0,0" />
Note: For Separator you may create a Style, because for him base type a Control (for Line -Shape).
I have defined a grid with some rows and two columns
In [0,0] I have placed an image with main attributes as below:
HorizontalAlignment="Left" VerticalAlignment="Center"
Stretch="None" Margin="10 0 0 0" Width="260"
And in [0,1] I have placed a label with some text in it with some main attributes like this:
HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="36" FontSize="16"
My question is why if I remove the width = 260 from image field then suddenly also the label in next column is disappearing? I think the image expands and covers it. But why? Shouldn't it be limited to its own [0,0] cell?
Your columns are autosizing to the size of their contents, so I would guess that your image in (0,0) isn't actually spreading into column 1 it is just that column 0 is growing so large that you can't see column 1 anymore.
If you make the column size * you will constrain it to the available space. As someone else said, you can use ShowGridLines to help debug what is going on with your columns, especially if you add a second row just to see where the division between your columns is.
I'm trying to use the padding property for a buttons Content, I want the padding the be done to the right (10px the the right) but when I use the padding prperty in my xaml like this :
Padding="0,0,10,0"
the text is on the left side of the button(close to the left border).
How can I padd to the right?
Thanks
<Button ... Padding="0 0 10 0" HorizontalContentAlignment="Right" />
This the correct behaviour. Padding puts space between your content and to your container.
The numbers go clokwise, starting at the left side.
If you want to see the text closer to the right border use Padding="10,0,0,0"