|
Data contexts are inherited. the data context for a control is automatically passed into all it's children unless it declares a different one for it's own.
So the data context for the window is automatically inherited by your UserControl.
PS: I assume your UserControl is a child of the window
|
|
|
|
|
|
Hi all,
I am newbie to WPF,need your guidance on richtextbox control.My application updating huge texts in richtextbox control,but the text gets overlap
here is my XAML code
<RichTextBox Height="476" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left" Margin="8,36,0,0" Name="dutRtx" VerticalAlignment="Top" Width="Auto" IsReadOnly="True" FontSize="11" FontFamily="Segoe UI" Cursor="Arrow">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="4pt"/>
<Setter Property="LineHeight" Value="6.3pt"/>
<Setter Property="FontSize" Value="9pt" />
<Setter Property="LineStackingStrategy" Value="BlockLineHeight" />
</Style>
</RichTextBox.Resources>
<FlowDocument>
<Paragraph FontSize="9pt" LineHeight="4pt" LineStackingStrategy="BlockLineHeight"></Paragraph>
<Paragraph>
</Paragraph>
</FlowDocument>
</RichTextBox>
Increasing the line height the line spacing will be higher.to tackle both line spacing and height...
provide your suggestions....
|
|
|
|
|
So I have spent the last hour or so ratting through Google results to see if there is any news on the future of Silverlight front. This is driven by my decision, 3+ years ago, to move our platform from winforms and click once deployment to Silverlight and a browser based interface.
The newly minted policy that the client could not connect directly to the server dictated WCF. We have been happily grinding out Silverlight apps for the last few years, we are VERY successful as supplying the business solutions.
It is now 2+ years since MS announced the death of SL and I'm pondering our next platform move. I have a wide choice of MS tech, I can go back to winforms, move to WPF and junk the browser altogether, this is sooo tempting.
The thought of going back to html and scripting just curls my toes, JSOPs declaration did not help. To add to the mix we are now getting a small but significant requirement for mobile apps, iOS and Andriod only, windows has no penetration on the mobile platform.
I seriously do not want to take a highly successful dev team down another blind route - again. I am so pissed with MS. But I can't identify an MS unified platform for LOB development and I don't want to take them away from their core skills, what a waste. For the moment we are staying with SL but I need to address mobile development as well.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
SL is dead for browser apps. Never really took off. HTML5 is the future there. WPF is the way to go for desktop apps, but desktop apps are a dying breed except for certain applications. You should have known 3+ yrs ago not to use SL. Writing was on the wall back then... was a proprietary thing from MSFT that only worked in very limited situations at the time.
|
|
|
|
|
You obviously read the wall better than I do, 3 years ago SL was still one of the only viable alternatives to aspx, proprietary or not I was willing to take on an MS platform. I know after 20+ year you would think I would have known better but I waited till SL was well entrenched in the development environment before I changed.
While HTML5 may be cross platform it seems to be an amorphous collection of bits and pieces that includes javascript, which I rate marginally higher than the defunct vb script. I don't want to go to something like Kendo or some other 3rd party framework and have to reskill an entire team on UI development using a minor exposure tool!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
My advice (which is probably worthless, but I'm giving it nonetheless).
JavaScript is a difficult language to learn well and to use well.
It is also a language that anyone can have a play with - and so there is a lot of crap javascript out there.
jQuery helps some - but again there is a big learning curve.
There are also other libraries (KnockoutJS being one I like) which can help.
It sounds like you are being proactive and so have some time before real development takes place.
I would task a dev or two to get into javascript / jQuery / Knockout and produce some exemplar apps - and document them to destruction.
Make sure they have done real-world things with the examples - you have existing code bases on which you can base these, so plop up a web service and re-engineer some of the stuff you have in Js/HTML5
With the luxury of time, you should end up with something you can all comfortably use without going down the 'quick - need to do it NOW even though I don't know it - oh! wait! this works, I'll leave it in the code for now!!' route.
Re-skilling is inevitable, really - so do it over time and do it well.
MVVM # - I did it My Way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011
.\\axxx
(That's an 'M')
|
|
|
|
|
Actually all of us have some exposure to javascript although for some it is a decade old .
I have no urgent need to move off the SL platform and we already have a couple of guys doing HTML5 work on the mobile front so I'm comfortable with where we are and the near future. We will end up going down the path of HTML5 by default but I just wish there was a solid frame work or set of tools I could identify.
I am severely tempted to go back to the desktop and clickonce as we are starting to integrate external apps and SL is too limited in this area.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello,
How do I please control (start, stop, pause, go to specific time) a controltemplate storyboard inside a custom control..by code?
The XAML:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Window6"
Title="MainWindow" Height="394" Width="324">
<Window.Resources>
<Style x:Key="Arrow" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}" x:Name="CTarrow">
<ControlTemplate.Resources>
<Storyboard x:Key="Storyboard1" RepeatBehavior="Forever" AutoReverse="True">
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="rectangle">
<DiscreteColorKeyFrame KeyTime="0" Value="#FF0080FF"/>
<DiscreteColorKeyFrame KeyTime="0:0:0.5" Value="#FF004D99"/>
<DiscreteColorKeyFrame KeyTime="0:0:0.8" Value="#FF0080FF"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Grid>
<ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Rectangle x:Name="rectangle" Height="30" Width="50" Fill="Black" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<Button HorizontalAlignment="Left" VerticalAlignment="Top" Style="{DynamicResource Arrow}" x:Name="Arrow" />
</Grid>
</Window>
In these 3 attemps, the debugger complains about not being able to resolve 'rectangle':
Dim myStoryboard As New Storyboard
myStoryboard = Arrow.FindResource("Storyboard1")
myStoryboard.Begin()
Dim myStoryboard As New Storyboard
myStoryboard = CType(Me.Resources("Storyboard1"), Storyboard)
myStoryboard.Begin(Arrow)
Dim myStoryboard As Storyboard = TryCast(Arrow.Template.Resources("Storyboard1"), Storyboard)
If myStoryboard IsNot Nothing Then
myStoryboard.Begin(Arrow)
End If
With this one, I can verify that neither the template is not found:
Dim ct As ControlTemplate = TryCast(Me.FindName("CTarrow"), ControlTemplate)
If ct IsNot Nothing Then
Debug.Print("ControlTemplate found")
Dim sb As Storyboard = TryCast(ct.Resources("Storyboard1"), Storyboard)
If sb IsNot Nothing Then
sb.Begin()
Debug.Print("Storyboard found")
End If
End If
Please help!!
modified 24-May-13 12:22pm.
|
|
|
|
|
Hello forum,
(sorry if duplicate, I might have post this but cannot find it)
Just created a SL Busines application. In the MYDomainService.cs the default queries are generated.
public IQueryable<dbtable> GetDBTablesCompare()
{
return this.ObjectContext.DBTables;
}
The default returns all columns in the specified table.
I would like to run a script like this:
SELECT * From DBTables A
FULL OUTER JOIN Information_Schema.Columns B ON A.Column_Name = B.Column_Name
AND B.Table_Name = 'FY2007_DATA'
AND B.Table_Schema = 'dbo'
WHERE
A.Table_Schema = 'dbo'
AND A.Table_Name = 'FY2006_DATA'
AND (A.Column_Name IS NULL OR B.Column_Name IS NULL)
Any help will be greatly appreciated
|
|
|
|
|
I have large amounts of text I'd like to format like Rich Text, except I'd like to be able to include Links, DropDowns, buttons, ect, int the text.
What's the right way to handle this in a WPF window? I'm thinking maybe some kind of wrap panel.
If it's not broken, fix it until it is
|
|
|
|
|
|
That's exactly what I wanted.
Thank you
If it's not broken, fix it until it is
|
|
|
|
|
Hi,
I have a WPF DataGrid made up of DataGridTemplateColumns, that have DatePickers.
I am selecting a particular cell as follows:
var cellToEdit = new DataGridCellInfo(row, column);
this.MyDataGrid.CurrentCell = cellToEdit;
What is happening is that I'm successfully moving to the cell that I want, however the cell in which I was before I moved, is remaining editable and loosing style.
I'm assigning a style in my DatePicker_GotFocus event. I have a handler for this event as follows:
AddHandler(DatePicker.GotFocusEvent, new RoutedEventHandler(DatePicker_GotFocus), true);
I'm noticing that DatePicker_GotFocus is being executed multiple times when moving to the new cell.
Any idea how to solve this issue?
|
|
|
|
|
I have a problem about change the datagrid's header style.
when you clicked the header of datagrid for sort,each time have a arrow icon。I do not want this,how to remove it,the arrow icon。
|
|
|
|
|
There is most certainly a propert of the datagrid that manages the sorting of column. CanSortColumns, or UserCanSort or AllowSort, just take a look through the properties of the datagrid control you are using.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello forum,
I’ve created a Silverlight application that includes a ADO Entity data model and DomainService class.
In the main page the context is created
MyDomainContext context = new MyDomainContext();
dataGrid1.ItemsSource = dp1;
context.Load(context.GetDBTablesQuery());
The default configuration (in MyDomainServices.cs)works fine.
For example, the following code populates a datagrid.
public IQueryable<dbtable> GetDBTables()
{
return this.ObjectContext.DBTables;
}
My question is: How do I run a simple script
(e.g. Select col1, col2 from DBTable where col1='12')
Many thanks in advance
|
|
|
|
|
I am trying to customize the StringFormat for my datepicker to 'yyyy/MM/dd'. How do I trigger DateValidationError event when the user enters the wrong format. Here's my code:
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="FontSize" Value="16"/>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<TextBox x:Name="PART_TextBox"
Text="{Binding Path=SelectedDate, StringFormat='yyyy/MM/dd',
RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Thanks
|
|
|
|
|
I have a WPF C# control that is being used inside a Dynamics AX application. I have set my code in WPF to handle the ENTER key as follows:
private void Datagrid_PreviewKeyDown(object sender, KeyEventArgs e)
{
switch (e.Key)
{
case Key.Enter:
{
// Code here that moves focus to the next cell
e.Handled = true;
break;
}
What is happening, is that when I press the ENTER key the control loses focus and goes out to the next control in AX.
Any way of preventing this, and leaving focus in the grid?
Thanks in advance.
|
|
|
|
|
This is very much a control specific issue, you are going to need to talk to the support forum for the control. It may have a property that will handle the behaviour. I would have thought the preview event should have grabbed the event before the control processes it!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I suggest not to use tunnelling event handling and go for standard bubble handling. Implement OnkeyDown instead and DO NOT set the handled property to true. It breaks WPF's default focus handling mechanism (the one used while pressing the tab key) and sometimes, with certain keys, causes weitrd problems.
|
|
|
|
|
Maybe I wasn't clear. I'm using a standard WPF DataGrid inside a WPF control.
I have now used the User Control (that has the DataGrid in it) PreviewKeyDown Event. and set e.Handled to false, with no luck.
The DataGrid_KeyDown & UserControl_KeyDown are not being executed.
I have even tried to use: System.Windows.Forms.SendKeys.SendWait("{TAB}"); (since I would like my ENTER key to behave as the TAB key)... however my functionality happening when pressing tab, as stated in the event GridView_KeyDown, is not being executed, apart from the focus going to the first cell of my DataGrid.
There is even a boolean property both in the user control and in the datagrid KeyboardNavigation.AcceptsReturn that didn't make any difference when setting true or false.
modified 22-May-13 2:36am.
|
|
|
|
|
I'll try to reproduce your case and say..
|
|
|
|
|
Hi,
I have always used MVVM with all the WPF projects I worked on. Recently I joined a firm where they seem to be using MVVMP pattern (http://www.overroot.com/blog/2011/03/16/how-to-implement-mvvmp-pattern/[^]). Whatever Google search I make around I MVVMP I am ending up at the blog mentioned above. I want to understand does any one else use MVVMP too? If so I want to understand the advantages of MVVMP over MVVM. Any links/references to the topic would be greatly appreciated.
Thanks!
Cheers,
Suresh
|
|
|
|
|
Just something some random dude on the internet made up when he was high. The blog you linked to makes almost no sense. His explanation of why MVVMP is better then MVVM is pretty much "its cooler if you split out your business logic into a separate class from the VM". Well, too bad that's really the models job .
|
|
|
|