|
It does, but the App.xaml makes no sense inside the class library.
|
|
|
|
|
Yes you are correct, it doesn't make sense in class library. But my requirement is sometime I need DLL and sometime EXE, so I am not removing App.xaml file.
|
|
|
|
|
That's just really weird, and not a requirement, it sounds like a solution to another requirement.
The 'normal' way would be move the common bits to a class library, then you have an exe that references that library.
You don't switch an exe to dll just by changing the project setup or visa versa.
|
|
|
|
|
It's not weird, if I want reference the DLL in multiple exe other than the exe which is generated from by changing project output type Windows Application.
|
|
|
|
|
If you want to reference the dll from multiple exe's(or other dll's) then that's exactly what a class library is for.
Why do you think you now need to change that same class library to an exe? what is the exe going to do?
|
|
|
|
|
This library contains XAML file, if I make exe of it then doesnt required to add reference of DLL.
|
|
|
|
|
Not sure I get you... but if you want a class library to contain xaml (Windows, Pages, UserControls etc) then it can do, and yes you might need to manually add some references to the default 'class library' visual studio template.
If you create a WPF app then obviously the template already contains all the basic references you need.
You still don't need to switch a single project between a class lib and an application types.
|
|
|
|
|
I want to add a table to a DockPanel. Please see the table demo.
The text are all hardcoded or variables in the code. All the numbers are from code, say fields.
What should I select, datagrid or grid or table.
Thanks for code snippet.
|
|
|
|
|
You need to use a data table, bind the ItemSource to your collection and define the DataColumns with Header and Binding
<DataGrid Grid.Row="1"
Name="dgDB"
AutoGenerateColumns="False"
CanUserAddRows="False"
ItemsSource="{Binding DatabaseList}"
SelectedItem="{Binding SelectedDatabase, Mode=TwoWay}"
Margin="15"
IsReadOnly="True"
MouseDoubleClick="GridClick">
<DataGrid.Columns>
<DataGridTextColumn Header="Database"
Width="*"
Binding="{Binding DatabaseName}" />
</DataGrid.Columns>
</DataGrid>
Instead of Row="1" you would use DockPanel
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, the data is not from database. Just several values, say:
IVR-Success=50;
IVR-Fail=2;
PAYMENT-Success=30;
PAYMENT-Fail=0;
CALL-Success=100;
CALL-Fail=2;
The total can be calculated. Just 3x3 table, no more rows or columns. Is it too complicated by using datagrid?
|
|
|
|
|
zhshqzyc wrote: Is it too complicated by using datagrid
Yes, the content is not dynamic so just place the labels and textboxes where they look good and bind each one to a single property in the VM.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello
I have change the value in the web.config to connect my project silverlight to database but I have this problem on this line:
public Viaccess.Vite.AdministrationSL.SvcAdmin.WcfResultOfArrayOfPackageBOx8pdn48J EndGetAllPCKs(System.IAsyncResult result)
{
object[] _args = new object[0];
Viaccess.Vite.AdministrationSL.SvcAdmin.WcfResultOfArrayOfPackageBOx8pdn48J _result = ((Viaccess.Vite.AdministrationSL.SvcAdmin.WcfResultOfArrayOfPackageBOx8pdn48J)(base.EndInvoke("GetAllPCKs", _args, result)));
return _result;
}
And the message is "The remote server returned an error: NotFound".
The project use WCF.
Thanks
(Sorry I'm french and my English is not very good)
|
|
|
|
|
No one is going to be able to help you with so little information and setting up a WCF config is difficult. What I do is to split the project into 2, WCF and UI.
I then build the wcf and run it locally and test the connection using the Wcf Test Client and pull back the GetData.
I then change the web config and include the client access policy and cross domain xml files. Youwill need to find a couple of decent examples to work from, this is my config file
="1.0"="UTF-8"
<configuration>
<configSections>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="40000"/>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicBinding"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="XXXPSsvcBehavior"
name="XXXPS.WCF.XXXPSsvc">
<endpoint address="XXXPSWCF"
bindingConfiguration="BasicBinding"
binding="basicHttpBinding"
contract="XXXPS.WCF.IXXXPSsvc" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="XXXPSsvcBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<appSettings>
<add key="DBServer" value="ServerName.arvixe.com" />
</appSettings>
</configuration>
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
when we use a NavigationService instance(nav) to navigate. then a NavigationWindow or Frame will add a journal automatically. sometime,we want to control this process. how to do it?
I just want to write a name to its stack. and dispose the privious page.
thanks.
|
|
|
|
|
Collin Jasnoch wrote: Like I would like to open a word doc with whatever application the user has installed and prefers for ".doc" files rather than forcing them to use a specific application that I assumed they have installed.
That part's easy - just pass the path of the file to Process.Start , and Windows will open it using the associated program.
Process.Start(@"C:\Path\To\Your\File.doc");
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
How would the DataTransferManager solve the issue of opening a document with the user-preferred application, rather than the current default application, if the user isn't going to configure that application in advance?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, but that's the first part of your question, which I didn't attempt to answer.
I was answering the second part:
Collin Jasnoch wrote: I would like to open a word doc with whatever application the user has installed and prefers for ".doc" files rather than forcing them to use a specific application that I assumed they have installed.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm still struggling to see how any API could use the user's preferred application, rather than the system default application, if the user hasn't configured anything.
Based on your previous messages, the user wants to open a text file in Notepad++, but the file association is configured to use Notepad. Unless the user changes that configuration, how would an API know to open the file in anything other than Notepad? Short of prompting the user every time you open a file, I don't see how that could work.
No matter how good the APIs are, I don't think Microsoft has invented a mind-reading API yet.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am new in wpf mvvm.I just follow codeproject Sample code.
Using WPF MVVM for Database Access[^]
The insert update all are working fine .but the validation is showing with textbox.I need to show the error message on button click.How can we do this error validation on button click?Can anyone help.
Thanks in advance
|
|
|
|
|
If you have a question about examples from an article, you should ask them on that article.
|
|
|
|
|
I am working on a WPF 4.0 app that calls to the back end via an MVC 4 Web API.
I have a view called Injuries. I have an InjuryEntity which contains an ObservableCollection of DocumentEntity.
I'm using an ObservableCollection because the WPF UI is bound as such:
<DataGrid Grid.Row="1"
Grid.Column="0"
Background="White"
ItemsSource="{Binding SelectedInjury.Documents}"
SelectedItem="{Binding SelectedDocument}"
AutoGenerateColumns="False"
FontSize="12"
FontWeight="Normal"
FontStyle="Normal"
IsReadOnly="True"
TabIndex="1200"
Height="130"
Margin="3">
When I call
InjuryEntity.Documents.Add()
everything works fine. I am able to save the data to the DB with no problem.
Now, when I call back into the API to get the Injuries, I get back null. The ENTIRE Injury entity is null, not just the documents.
If I make the ObservableCollection into List<>, then the data comes back fine.
I'm using ObservableCollection because in injury entity's Documents collection makes use of the Collection_Changed event so that I can do:
Documents = new List<InjuryDocumentsEntity>();
Documents.CollectionChanged += Documents_CollectionChanged;
private void Documents_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
RaisePropertyChanged("Documents");
}
This allows the data grid and other UI elements the be refreshed as soon as a collection item changes.
So, the problem appears to be that MVC 4 doesn't like ObservableCollection.
I've been Googling, but I'm not finding much help.
Can anyone shed some light on this?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
It sounds like a serialization problem.
Have the API return a List<> , and map that to an ObservableCollection<> in your view model.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm working through the excellent book "Windows Presentation Foundation 4.5 Cookbook" by Pavel Yosifovich, trying to broaden my skill set. I'm at the 70% mark according to my Kindle Reader and still asking "why?" I don't normally like to copy the downloaded code because I learn a great deal by typing the code in and troubleshooting my errors. I finally threw in the towel with the code I will insert at the end of this post. My main aggravation is trying to use XAML to design graphical interfaces. I find it impossible to picture in my head anything but the simplest constructs. This may be a deficiency on my part but please, looking at the templates below created in App.xaml who can really tell what this is going to look like? Many lines of dense code that can't be viewed until the syntax is completely correct AND the template is used in a window.
I understand that there are tools like Blend which begs the question "Why isn't blend the default WPF design tool in Visual Studio?" Are there tools for visualizing, maybe even creating, templates?
I intend to work through the remaining chapters in this book and then explore the tools available in Blend and only use XAML to tweak. Is anyone else with me here?
Code:
<Application x:Class="CH08.CustomScrollBars.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ControlTemplate TargetType="RepeatButton" x:Key="repeatTransTemplate">
<Rectangle Fill="Transparent" />
</ControlTemplate>
<ControlTemplate TargetType="RepeatButton" x:Key="plainTemplate">
<Grid>
<ContentPresenter Margin="{TemplateBinding Padding}" />
</Grid>
</ControlTemplate>
<ControlTemplate TargetType="Thumb" x:Key="vthumbTemplate">
<Rectangle RadiusX="5" RadiusY="10" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"
Fill="{TemplateBinding Background}" />
</ControlTemplate>
<ControlTemplate TargetType="ScrollBar" x:Key="verticalScrollBarTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderBrush="DarkBlue" BorderThickness="1" Background="LightBlue" Grid.Row="1">
<Track x:Name="PART_Track" IsDirectionReversed="True">
<Track.DecreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageUpCommand" Template="{StaticResource repeatTransTemplate}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageDownCommand" Template="{StaticResource repeatTransTemplate}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Template="{StaticResource vthumbTemplate}" BorderBrush="Black" BorderThickness="1">
<Thumb.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Offset="0" Color="DarkGreen" />
<GradientStop Offset="1" Color="LightGreen" />
</LinearGradientBrush>
</Thumb.Background>
</Thumb>
</Track.Thumb>
</Track>
</Border>
<Viewbox>
<RepeatButton Command="{x:Static ScrollBar.LineUpCommand}" Template="{StaticResource plainTemplate}">
<Path Data="M 25,0 L 50,50 L 0,50 Z" Fill="Blue" />
</RepeatButton>
</Viewbox>
<Viewbox Grid.Row="2">
<RepeatButton Command="{x:Static ScrollBar.LineDownCommand}" Template="{StaticResource plainTemplate}">
<Path Data="M 25,50 L 0,0 L 50,0 Z" Fill="Blue" />
</RepeatButton>
</Viewbox>
</Grid>
</ControlTemplate>
<ControlTemplate TargetType="Thumb" x:Key="hthumbTemplate">
<Rectangle RadiusX="10" RadiusY="5" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"
Fill="{TemplateBinding Background}" />
</ControlTemplate>
<ControlTemplate TargetType="ScrollBar" x:Key="horizontalScrollBarTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border BorderBrush="DarkBlue" BorderThickness="1" Background="LightBlue" Grid.Column="1">
<Track x:Name="PART_Track" IsDirectionReversed="False">
<Track.DecreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageLeftCommand" Template="{StaticResource repeatTransTemplate}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageRightCommand" Template="{StaticResource repeatTransTemplate}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Template="{StaticResource hthumbTemplate}" BorderBrush="Black" BorderThickness="1">
<Thumb.Background>
<LinearGradientBrush EndPoint="1,0">
<GradientStop Offset="0" Color="DarkGreen" />
<GradientStop Offset="1" Color="LightGreen" />
</LinearGradientBrush>
</Thumb.Background>
</Thumb>
</Track.Thumb>
</Track>
</Border>
<Viewbox>
<RepeatButton Command="{x:Static ScrollBar.LineLeftCommand}" Template="{StaticResource plainTemplate}">
<Path Data="M 0,25 L 50,50 L 50,0 Z" Fill="Blue" />
</RepeatButton>
</Viewbox>
<Viewbox Grid.Column="2">
<RepeatButton Command="{x:Static ScrollBar.LineRightCommand}" Template="{StaticResource plainTemplate}">
<Path Data="M 0,0 L 50,25 L 0,50 Z" Fill="Blue" />
</RepeatButton>
</Viewbox>
</Grid>
</ControlTemplate>
<Style TargetType="ScrollBar">
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Template" Value="{StaticResource verticalScrollBarTemplate}" />
</Trigger>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Template" Value="{StaticResource horizontalScrollBarTemplate}" />
</Trigger>
</Style.Triggers>
</Style>
</Application.Resources>
</Application>
|
|
|
|
|
Nah. "Cookbooks" are only useful if you already have a basic understanding of the overall subject matter (IMO), and you have a particular problem / question in mind.
In particular, the sample XAML you posted deals with "resources, styles, commanding, templating, triggers, ..."; stuff that is typically found in "later chapters".
One of the best books I found for learning WPF is: Illustrated WPF by Daniel Solis.
Also, there's a free tool out there for coding and visualizing XAML called XAMLPad that you may find useful:
http://msdn.microsoft.com/en-ca/library/vstudio/ms742398(v=vs.90).aspx[^]
It's been around for a while and may not have been updated, but it is still useful for learning.
I don't use a XAML visual designer. If you keep in mind that your XAML is just one big "tree"; that you can collapse and expand; and explore using the VS "Document Outline" window; then everything just falls nicely into place (after a while).
(BTW, the posted XAML is more-or-less like a "library" of templates; not particularly useful for visualizing a "form", per se. The templates / styles are used to alter the appearance of controls used in "real" forms / windows. Just fiddling with appearances; mostly.)
modified 17-Oct-14 17:29pm.
|
|
|
|
|
Programming is daunting in most shapes and sizes given code or starting from scratch. Biggest hurdle perhaps, choosing a platform and/or language. But ... wait a minute ... how would I be able to chose anything unless I had Visual Studio?
I suspect the place one needs to to go when they get confused then, is:
https://code.msdn.microsoft.com/[^]
Punch in the tools you have, get the samples, open them in VS.
Now tell us how difficult WPF is through VS.
|
|
|
|