|
Use a
ScrollViewer control.
|
|
|
|
|
I have a UI with a MainWindow, which has a tab control. Some of those tabs have child tabs. So for Main Tab 1 there are 3 Child Tabs.
When the user selects Main Tab 1, Child Tab B, then clicks File->Print on the menu, how would you pass that menu command to the Active tab? Or somehow notify the ACTIVE TAB to print?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Bind the TabControl.SelectedIndex
<telerik:RadTabControl Grid.Column="2" SelectedIndex="{Binding SelectedTab,Mode=TwoWay}">
Telerik has that property not sure if the standard TC does.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Did you even read the question?
What does binding the tab's SelectedIndex have to do with the Menu's Print command getting paassed all the way down the visual tree??
If it's not broken, fix it until it is
|
|
|
|
|
I assumed you are doing the printing from the VM, forgot you have your odd printing method.
Still I would do it the same anyway, tab changed is bound to the VM and sets the active tab, Print command tells a VM property for each tab to print. Seems like a complete kludge but then you have a creative printing method!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If the TabControls are implemented as a List of Lists of TabControls (or similar) in your AppComposer file (or App.xaml.cs, wherever you defined them), you could just go through said list(s) and look for the TabControl.SelectedTab property.
Once you get hold of the active/selected tab that way, you could notify it to print.
Edit:
Just noticed that's about the same as what Mycroft suggested...but I would go for it as a first approach anyway
|
|
|
|
|
Does anyone know how to change the Spell Checking language of a WPF TextBox control to UK English.
I have tried setting Language="en-GB' and xml:lang="en-GB" as advised on all the websites - it does not work!
The software I am writing is literacy software (XAML Front end, C# Code Behind) for an education centre and needs to spell check in UK english
It seems really strange that WPF does not support UK English
- Windows does??
I have done this in a previous version of the software, but I think I implemented it as WinForms and maybe used a Word Interop for spell checking - but I cannot be sure that the users will have Word installed . . .
Please, Please, Help!
I read somewhere I can add a custom dictionary for UK English
anyone know where I can get one in .lex format
I have a file with all the differences between UK and US English - can I use this somehow
|
|
|
|
|
|
Hmm . . . thanks Muhammad, I tried that, it did not work for me, thanks for your answer
OK, I finally figured it out
I can set the default language once for the whole application using:
<i>// Set default language to UK English . . .</i>
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-GB");
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name)));
After that, all TextBoxes and RichTextBoxes use UK English for SpellChecking
Many Thanks for all your help
|
|
|
|
|
I am trying to put a WPF Control in a winform for a project at work. I have done before for small controls and it worked well. I even put the DiagramDesignerPart1 in a winform as a practice run and did ok but some of the resources were missing and I did not notice or did not think it was a big deal.
Now I am trying to put the DiagramDesignerPart4 in a winform panel and the resources are missing at runtime.
The control shows all the resources at design time but when I run they are missing.
Also if I set the project to startup project that window runs fine and the resources all show up.
I have searched and searched for the answer and have not been able to get anything to work for me.
I did the following
1) I added the project to my project
2) Created a WPF Control and called it DiagramEditor and copied the xaml code into that to change it from a application to a control
3) I created a themes/generic.xaml file to put the info that was in app.xaml there
First I had a problem with the program crashing runtime using the static resources and the error was that it could not find the resources.
Then I changed to DynamicResources and it runs but none of the resources are showing up.
Generic.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DiagramDesigner">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/Shared.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/ToolBar.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/GroupBox.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/Expander.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/ScrollBar.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/ApplicationToolbar.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/DesignerItem.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/ToolboxItem.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Toolbox.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Connection.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Stencils/FlowChartStencils.xaml"/>
<ResourceDictionary Source="/DiagramDesigner;component/Resources/Stencils/ShapeStencils.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type local:DiagramEditor}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:DiagramEditor}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
DiagramEditor.xaml
<UserControl x:Class="DiagramDesigner.DiagramEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="clr-namespace:DiagramDesigner"
xmlns:c="clr-namespace:DiagramDesigner.Controls"
mc:Ignorable="d"
d:DesignHeight="850" d:DesignWidth="1000">
<UserControl.Resources>
<ContextMenu x:Key="DesignerCanvasContextMenu">
<MenuItem Header="Paste" Command="{x:Static ApplicationCommands.Paste}">
<MenuItem.Icon>
<Image Source="/Resources/Images/Paste.png" Width="16"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Select All" Command="{x:Static s:DesignerCanvas.SelectAll}"/>
</ContextMenu>
</UserControl.Resources>
<Grid>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ContentControl Content="{DynamicResource MyToolbar}"/>
<Grid Grid.Row="1" Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="265"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="0,0,5,0">
<Expander Header="Flow Chart" Content="{DynamicResource FlowChartStencils}" IsExpanded="True"/>
<Expander Header="Shapes" Content="{DynamicResource ShapeStencils}" IsExpanded="True"/>
</StackPanel>
<GridSplitter Focusable="False" Width="2" Background="LightGray"
VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
<GroupBox Header="Diagram" Grid.Column="1" Margin="3,0,0,0">
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<s:DesignerCanvas Focusable="true" x:Name="MyDesigner"
Background="{DynamicResource WindowBackgroundBrush}"
Margin="10" FocusVisualStyle="{x:Null}"
ContextMenu="{DynamicResource DesignerCanvasContextMenu}"/>
</ScrollViewer>
</GroupBox>
</Grid>
</Grid>
</Grid>
</UserControl>
code to put on winform
System.Windows.Forms.Integration.ElementHost elementHost1 = new System.Windows.Forms.Integration.ElementHost();
DiagramEditor diagramEditor = new DiagramEditor();
private void LoadControls()
{
elementHost1.Dock = DockStyle.Fill;
elementHost1.BackColorTransparent = true;
elementHost1.Child = diagramEditor;
panel1.Controls.Add(elementHost1);
}
|
|
|
|
|
|
Thanks, I read in one of the many pages I looked at that we should have a generic file and the folder is created when we create a new custom control. I never saw this question in my list so I did not think it had posted, but I got the problem resolved by putting the resource links in The control resources and the window resources in those xmal files. I also had to change most of the static resources to dynamic resources. So far I just put the page on a panel in my winform app and did a little testing but the major revamp will come next week as I add stuff to it .
|
|
|
|
|
City Names City1 City2 City3 City4 City5 City6 City7 City8
City1 1 1 2 1 2 1 2 3
City2 1 1 2 1 2 1 1 2
City3 1 2 1 2 2 2 2 2
City4 2 1 2 1 2 2 2 1
City5 1 2 1 3 1 3 2 3
City6 2 2 2 2 3 1 1 2
City7 1 1 2 1 2 1 1 1
City8 2 1 3 1 3 2 1 1
I need to create this kind of Editable Datagrid Using MVVM if some one have this kind of data grid development experience please help me ..
(this numbers are distance between two city's it should be display inside of textbox component )
thanks..
|
|
|
|
|
|
Great link.
The first time I've seen someone admit that MVVM does NOT mean you NEVER have code behind.
He articulated what I always thought of as "display logic"; that every MVVM "fan" twists themselves into knots over trying to avoid.
|
|
|
|
|
It's well-written too. Hope you upvoted the article
|
|
|
|
|
Hi All,
I am using the following View and View Model in VB.Net, when I am trying to reference the View Model as DataContext
View is like this below
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
xmlns:empns="clr-namespace:TestWPFVBApplication.ViewModel"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<empns:EmployeeViewModel x:Name="_employeeViewModel" EmpId="1" EmpName="Abdul" EmpSalary="10000.00"
DeptId="1">
</empns:EmployeeViewModel>
</Window.DataContext>
<Grid>
</Grid>
</Window>
And my View Model is as below
Namespace TestWPFVBApplication.ViewModel
Public Class EmployeeViewModel
Implements INotifyPropertyChanged, IDataErrorInfo
Private _empId As Integer
Public Property EmpId() As Integer
Get
Return _empId
End Get
Set(ByVal value As Integer)
_empId = value
NotifyPropertyChanged("EmpId")
End Set
End Property
Private _empName As String
Public Property EmpName() As String
Get
Return _empName
End Get
Set(ByVal value As String)
_empName = value
NotifyPropertyChanged("EmpName")
End Set
End Property
Private _empSalary As Decimal
Public Property EmpSalary() As Decimal
Get
Return _empSalary
End Get
Set(ByVal value As Decimal)
_empSalary = value
NotifyPropertyChanged("EmpSalary")
End Set
End Property
Private _deptId As Integer
Public Property DeptId() As Integer
Get
Return _deptId
End Get
Set(ByVal value As Integer)
_deptId = value
NotifyPropertyChanged("DeptId")
End Set
End Property
Private _employees As ObservableCollection(Of Employee)
Public Property Employees() As ObservableCollection(Of Employee)
Get
Return _employees
End Get
Set(ByVal value As ObservableCollection(Of Employee))
_employees = value
NotifyPropertyChanged("Employees")
End Set
End Property
Private _error As String
Public ReadOnly Property [Error] As String Implements IDataErrorInfo.Error
Get
Return _error
End Get
End Property
Default Public ReadOnly Property Item(columnName As String) As String Implements IDataErrorInfo.Item
Get
If (columnName = "") Then
Return _error
End If
Return String.Empty
End Get
End Property
Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
Private Property CanExecute As Boolean
Private Sub NotifyPropertyChanged(propertyName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub
Private _clickSaveCommand As ICommand
Public ReadOnly Property ClickSaveCommand() As ICommand
Get
Return If(_clickSaveCommand, (InlineAssignHelper(_clickSaveCommand, New SaveEmployeeCommand(Sub() AddAnItem(), CanExecute))))
End Get
End Property
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
Private Sub AddAnItem()
_employees.Add(New Employee(_empId, _empName, _empSalary, _deptId))
End Sub
End Class
End Namespace
And I am trying to reference the View Model as below
xmlns:empns="clr-namespace: TestWPFVBApplication.ViewModel.EmployeeViewModel"
And DataContext as below
<Window.DataContext>
<empns:EmployeeViewModel x:Name="_employeeViewModel" EmpId="1" EmpName="Abdul" EmpSalary="10000.00"
DeptId="1">
</empns:EmployeeViewModel>
</Window.DataContext>
Then its giving me error, please help me any ideas or links or even suggestions would help me greatly.
Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 26-May-16 19:08pm.
|
|
|
|
|
Try taking the space out from between "clr-namespace:" and the namespace:
xmlns:empns="clr-namespace:TestWPFVBApplication.ViewModel.EmployeeViewModel"
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I tried no use, nothing changed.
Here is that, but still it says the EmployeeViewModel is not in that namespace. Anyhelp please?
xmlns:empns="clr-namespace:TestWPFVBApplication.ViewModel"
And Error is:
EThe name "EmployeeViewModel" does not exist in the namespace "clr-namespace:TestWPFVBApplication.ViewModel".
<pre>
<div class="signature">Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."</div>
modified 26-May-16 19:08pm.
|
|
|
|
|
We are getting this error on a WPF to WCF application, mostly when the user wants to upload a file, the files are generally fairly small 200-300kb. It happens mostly for a WAN connection but has happened locally as well.
I have synched the web config and the client values. They are all maxed to int.MaxValue. We have even resorted to setting the MaxItemsInObjectGraph for each method on the client and we still get the error intermittently.
I enclose the code for getting the service client. Any suggestions will be appreciated and followed up assiduously.
static NPAFinSvcClient GetNPAFinServiceClient()
{
string url = string.Empty;
~#if DEBUG
url = "http://localhost:49223/NPAFinSvc.svc";
~endif
NPAFinSvcClient client = new NPAFinSvcClient(GetBinding(), new EndpointAddress(new Uri(url, UriKind.RelativeOrAbsolute)));
foreach (OperationDescription op in client.ChannelFactory.Endpoint.Contract.Operations) {
DataContractSerializerOperationBehavior dataContractBehavior = op.Behaviors.Find<DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
if (dataContractBehavior != null)
{
dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
}
}
client.Open();
return client;
}
static BasicHttpBinding GetBinding()
{
~if Release
var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
~else
var binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
~endif
binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxBufferSize = int.MaxValue;
binding.SendTimeout = new TimeSpan(2, 0, 0);
binding.ReceiveTimeout = new TimeSpan(2, 0, 0);
binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
binding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
binding.ReaderQuotas.MaxDepth = int.MaxValue;
binding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
return binding;
}
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You missed
maxBufferPoolSize
(Defaults to .5 mb?)
|
|
|
|
|
Thank you I will see if that relieves the problem
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Bugger, no change China still has trouble uploading a file.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I would like to bind a nested property of an attached Property
public class MyTag
{
public decimal MyValue { get; set; }
public string MyDescription { get; set; }
public bool Enabled { get; set; }
}
Build the attached property.....
public class Attached : DependencyObject
{
public static readonly DependencyProperty MyTagProperty =
DependencyProperty.RegisterAttached("MyTag", typeof(MyTag), typeof(Attached),
new FrameworkPropertyMetadata(null,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Inherits));
public static MyTag GetMyTag(DependencyObject dObj)
{
return dObj.GetValue(MyTagProperty) as MyTag;
}
public static void SetPLCTag(DependencyObject dObj, MyTag value)
{
dObj.SetValue(MyTagProperty, value);
}
}
and would like to bind in xaml like this
<Button
x:Name="button"
Width="75"
general:Attached.MyTag="{Binding First}" // First is an object of type MyTag
Content="{Binding Path=(general:Attached.MyTag.MyValue)}"/>
|
|
|
|
|
I've written a "typical" WPF application that utilizes data binding and displays a number of "slides". To view these slides, the user selects one from a ListBox.
One of the requirements is to save the selected slide as both a JPG and Power Point slide. This works great.
The other method for saving the slides allows the user to save all of the slides with the click of a single button (without selecting one first). The idea is to create the slide in memory, and save it. The problem is that any bound elements on the slide do not get included in the saved image.
This is the code I use to "render" the card in memory:
CtrlMySlide slide = new CtrlMySlide();
slide.Visibility = System.Windows.Visibility.Visible;
Dispatcher.Invoke(new Action(() =>
{
slide.RenderCard(this.FiscalPeriod, item, true);
slide.Measure(new Size(1024d,768d));
slide.Arrange(new Rect(0,0,1024,768));
slide.UpdateLayout();
}), DispatcherPriority.ApplicationIdle, null);
slide.Save(result, true);
EDIT ===================
I also tried creating a modal window and rendering the slides to that window. Same result.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 24-May-16 10:39am.
|
|
|
|