|
I have user control that i wrote.
this user control is appear on some Window ( host ) and the window size is dynamic.
I want to make the user control size to be also dynamic - and if the window host size is change ( grow / shrink ) then the user control also will change.
I try a lot of thinks - but the user control size is not changing ( also try to mark the user control as 'fill' and its not working. )
How to do it ?
Thanks
|
|
|
|
|
Things to check:
1) Does the container (The UserControl's parent) have its HorizontalContentAlignment and VerticalContentAlignment set to Stretch?
2) Does the UserControl have its HorizontalAlignment and VerticalAlignment set to Stretch?
3) Are you sure the UserControl isn't already stretching? Set its background to an obvious color. Maybe the stuff INSIDE your control isn't resizing.
|
|
|
|
|
Hi,
I have a query that returns a lot of records. What I have done to optimize the initial data bind when setting ItemsSource is to only show the first 100 records.
However, I allow users to gain access to the remaining records by indicating there are more records and if they press a button, all the records are bound to the DataGrid. This setting of ItemsSource takes 10-15 seconds.
I don't mind how long that takes, but I have a storyboard animation that I overlay to let the user know something is happening. This animation is fine whilst querying and binding 100 records (must be quick), but when binding 1000+ records, the animation doesn't run.
I'm presuming this is because the binding and the animation are on the UI dispatcher thread, but this is kind of defeating my ability to keep the user in the loop in what is going on.
Has anyone solved this issue, either by doing it right (am I doing something wrong?) or by doing it another way?
Thanks for any advice.
Simon
|
|
|
|
|
<code><pre>
Public WithEvents hyperLink As New Hyperlink()
~~~~~~~~~~~~~~~~~
For Each Lists As Status In Some.Status
TextBlock.Margin = New Thickness(4)
TextBlock.TextWrapping = TextWrapping.Wrap
hyperLink = New Hyperlink() With {.NavigateUri = New Uri("ok://" & Lists.Text)}
hyperLink.Inlines.Add("OK")
TextBlock.Inlines.Add(Lists.Text)
TextBlock.Inlines.Add(hyperLink)
Grid.SetColumn(TextBlock, 1)
Grid.SetRow(TextBlock, grdList.RowDefinitions.Count - 1)
grdList.Children.Add(TextBlock)
Next
Private Sub hyperLink_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles hyperLink.Click
MsgBox("Here I want to put a hyperlink address.")
End Sub
</pre></code>
The above code is the approximate.
Look at the relevant section in the code above hyperlink, add a hyperlink to the Grid can be found.
Yeah, but added to the first hypertext link event occurs.
Only first hyperlink.
What should I do all the hyperlinks that event occurs?
|
|
|
|
|
rus204 wrote: TextBlock.Margin = New Thickness(4)
I am not sure that I understand your question but when you run this loop, you only add the hyperlink to one textblock. So only the first event fires.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Is there a decent way?
TextBlock.Margin = New Thickness(4) is margin is too narrow to declare.
|
|
|
|
|
rus204 wrote:
Yeah, but added to the first hypertext link event occurs.
Only first hyperlink.
How do you attach hyperLink_Click to click event?
|
|
|
|
|
I was declared hyperlink as WithEvents.
So I can add a Click event.
|
|
|
|
|
Your english is quite poor or i do not understand what you want to ask.
You said First Hyperling, do you mean it will fire event when you click firt hyperling on list, or does it fire once where you click any hyperlings on list?
I think it is a second. As again, How do you asign Click event? Your answer was not good enough. I am C# developer.
are you using System.Windows.Documents.HyperLink from PresentationFramework.dll? if so do you aware that each hyperling has its own click event?
|
|
|
|
|
second you think is right.
and.. I'm not using PresentationFramework.dll
(I'm not one English-speaking countries. So I do not speak English very well. Sorry)
|
|
|
|
|
there is a possiblity you need to move event decleration (xaml) on a logic list or force a focus to element
|
|
|
|
|
What does that mean?
Some do not understand.
|
|
|
|
|
Can you paste a XAML sample, where it contains grdList and event hyperLink_Click. Not a code
For setting focus, you can use:
grdList.SetFocus();
This example is in C#. Veary easy to convert to VB.NET. But i do not know Syntax for vb.net
|
|
|
|
|
Ah! I've solved this problem.
Thank You!
|
|
|
|
|
How can I tell whether a Silverlight Textbox vertical scrollbar is visible or not?
When the text is short the scrollbar is hidden. When the text is long it's shown. Is there a means to check if the vertical scrollbar is visible?
Thanks in advance,
marcelo
|
|
|
|
|
Try putting this code in the textBox.Loaded event handler:
ScrollBar verticalScrollBar = ((FrameworkElement)VisualTreeHelper.GetChild(viewer, 0)).FindName("VerticalScrollBar") as ScrollBar;
verticalScrollBar.ValueChanged += (s, ev) => button.Visibility = System.Windows.Visibility.Collapsed;
I got his code from here (google is your friend, btw):
http://www.c-sharpcorner.com/Blogs/BlogDetail.aspx?BlogId=3703[^]
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Thank you very much, John
|
|
|
|
|
For ListBoxes it's as easy as this:
lbRecipients.GetScrollHost().ComputedVerticalScrollBarVisibility
|
|
|
|
|
hi,
i am using visual studio 10 professional for my silverlight project
first of all - i mannaged to show my webcam output on a rectangle located on the webpage. (yeepee for me
the problem is - when i run the app with my visual studio debugger and its time for the webcam to ask for access appoval i get a window saying:
"protection error
Dubgger detected - please close it down and restart!"
i assume there is some protection on my machine that protects it from running my webcam stream from a running debugger (vs 10 in this matter)
is there a way to go around it ? i hate to be able to run my code only at the website.
tnx in advance
|
|
|
|
|
Do you have Nero installed at all? It seems there's a problem with Nero's DirectShow filter which causes this error.
|
|
|
|
|
you mean Nero the disc burner?
i got it , its not running thow.
what do you think i should do ?
shall i 'burn' it?
|
|
|
|
|
shabya wrote: you mean Nero the disc burner?
Yes.
shabya wrote: i got it , its not running thow.
It doesn't need to be. There have been lots of reports of Nero causing this problem.
shabya wrote: what do you think i should do ?
Try uninstalling it.
|
|
|
|
|
I encounter a problem that I cannot solve. I hope to find an answer here. I need a listbox to hide half way when a certain listboxitem is selected. I setup a storyboard with opacity mask animation which work fine in blend. My problem I cannot initiate BeginStoryboard. I tried numerous ways and no success. I need to hide the listbox to reveal the content behind it. I generate listboxitems from XML data file and based on the name node I planned to initiate storyboard playing.
Here what I have. I created DataTemplate which I set via Setter in ListBoxItem Style:
<DataTemplate x:Key="SelectedListBoxItemDataTemplate">
<StackPanel x:Name="DataItemSelected" Orientation="Horizontal" Margin="12,0,0,0" >
<TextBlock FontFamily="Arial" Text="►" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding XPath=state}" Margin="-4, 0,6,4"/>
<Image x:Name="ListBoxImage" Source="{Binding XPath=icon}" Margin="4,4,14,4" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Uniform" />
<TextBlock x:Name="textBlock" Text="{Binding XPath=name}" FontFamily="Segoe UI Light" LineHeight="22" Foreground="#FFFFFFFF" FontSize="16" />
<Border x:Name="PART_Icon" Background="{x:Null}" Width="{Binding NodeValue.Width}" HorizontalAlignment="Left" Padding="3,0"></Border>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding XPath=name}" Value="SERVERS">
<Setter TargetName="PART_Icon" Property="Background" Value="Black" />
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource HideListBox}" x:Name="HideListBox_BeginStoryboard"/>
</DataTrigger.EnterActions>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
I need to run this storyboard which I keep in Window.Resources:
<Storyboard x:Key="HideListBox">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.OpacityMask).(GradientBrush.GradientStops)[0].(GradientStop.Offset)" Storyboard.TargetName="Nav_ListBox">
<EasingDoubleKeyFrame KeyTime="0" Value="0.069"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.OpacityMask).(GradientBrush.GradientStops)[1].(GradientStop.Offset)" Storyboard.TargetName="Nav_ListBox">
<EasingDoubleKeyFrame KeyTime="0" Value="0.069"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.OpacityMask).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="Nav_ListBox">
<EasingColorKeyFrame KeyTime="0" Value="White"/>
<EasingColorKeyFrame KeyTime="0:0:0.4" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.OpacityMask).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="Nav_ListBox">
<EasingColorKeyFrame KeyTime="0" Value="#00000000"/>
<EasingColorKeyFrame KeyTime="0:0:0.4" Value="#00000000"/>
</ColorAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.OpacityMask).(LinearGradientBrush.StartPoint)" Storyboard.TargetName="Nav_ListBox">
<EasingPointKeyFrame KeyTime="0" Value="1.076,0.501"/>
<EasingPointKeyFrame KeyTime="0:0:0.4" Value="1,0.5"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.OpacityMask).(LinearGradientBrush.EndPoint)" Storyboard.TargetName="Nav_ListBox">
<EasingPointKeyFrame KeyTime="0" Value="0.035,0.501"/>
<EasingPointKeyFrame KeyTime="0:0:0.4" Value="0.2,0.5"/>
</PointAnimationUsingKeyFrames>
</Storyboard>
I am getting errors that "Nav_ListBox" object cannot be found. I understand that listbox object is not avaible from the datatemplate level. I am wondering what will be the right solution to enable animation to play and eventualy to remove on click the othe listboxitem. Thank you in advance.
|
|
|
|
|
Move the Storyboard into the DataTemplate.Resources rather than out in a separate section. Basically, you are running into namescope issues here and moving the storyboard inside the same template should help.
|
|
|
|
|
Hi Experts,
I have a user control which is having a listview inside it. The SelectionChanged event of this list view is handled inside the user control. The code for the same is as follows:
private void lstvMyView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{...}
I want to call this handler again from some other place inside the user control. So to call this handler i need the "SelectionChangedEventArgs" there. When I am trying to create the instance of "SelectionChangedEventArgs", i am unable to understand what should I pass as parameters to the constructor of "SelectionChangedEventArgs".
The place from where I am suppose to call this handler does not add or remove any items in the listview. It just navigates in the items in the listview thereby changing the selectedindex of the listview.
I am trying to do something like this. The below code is obviously incorrect.
lstvMyView_SelectionChanged(_lstvMyView, new SelectionChangedEventArgs());
Please Help!
Thanks in Advance!
Regards,
Samar
modified on Wednesday, September 29, 2010 4:42 AM
|
|
|
|