|
Go back and start again, you have completely the wrong idea of how WPF is designed to work. Under no circumstances should you be looping through a xaml control.
WPF is all about binding, first you make your class observable by implementing INotifyChange (this is really easy) then you have an ObservableCollection of your class (system.Collections.Object) which you bind to your datagrid.
When an item is changed in your collection set a flag. When the user saves \then iterate the COLLECTION not the control.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have this Border with a Drop Shadow. I would like to Color and ShadowDepth values of the DropShowEffect with a MouseOver trigger, except I can't seem to figure out where to put the trigger.
Anyone know how to do this?
<Border CornerRadius="35,7,7,35">
<Border.Background>
<LinearGradientBrush StartPoint="0,0"
EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Goldenrod"
Offset="0" />
<GradientStop Color="White"
Offset=".5" />
<GradientStop Color="Gold"
Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect Color="LightGray"
ShadowDepth="5"
RenderingBias="Quality"/>
</Border.Effect>
</Border>
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Hello,
How do i use ResourceDictionary?
I created a xaml file with resourceDictionary with ImageSource
Than in my UserControl i must to mention a key for the resourceDictionary (otherwise it doesn't compile):
<ResourceDictionary x:Key="resourceDictionary">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/AQUA.ClientServices.Presentation;component/Images/ImageResources.xaml">
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
But when i am trying to use one of the resources in the dictionary it says the resource key can't be found
|
|
|
|
|
Have you inserted this code within your App.xaml file? If not, place in App.xaml file and remove the key attribute all together
<Application x:Class="MyWpfApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/AQUA.ClientServices.Presentation;component/Images/ImageResources.xaml">
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Hopefully that will help
"You get that on the big jobs."
|
|
|
|
|
I right my application using PRISM and my user control is a module.
How can i define to use the resource dictionary in the scope of the userControl ?
|
|
|
|
|
I don't do PRISM but I still think you want to get rid of the x:key. Also the / in front of AQUA doesn't look right either. Try removing that as well.
"You get that on the big jobs."
|
|
|
|
|
I was thinking about creating a WPF app. The main window would have a background like this[^].
Any reason not to use an image of some kind, or is it better to try to do the graphic in XAML?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Hi there I want a great HTML editor in WPF. So for this what I did is that I added a WebBrowser to WPF window and navigated it to the html page with the TinyMCE html editor in it. However when I rin the app, the browser control shows the script warning as follows:
http://s13.postimage.org/rod6itsjb/brerr.png[^]
XAML
<Window x:Class="TinyMceWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<WebBrowser Name="webBrowser1" Margin="0,0,0,54" />
<Button Content="Get Html" Height="31" HorizontalAlignment="Left" Margin="22,0,0,17" Name="btnGetHtml" VerticalAlignment="Bottom" Width="108" Click="btnGetHtml_Click" />
</Grid>
</Window>
XAML.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TinyMceWpf
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
webBrowser1.Navigate(new Uri(@"C:\Users\MAHESH\Desktop\TechNode\WPF\MytTechDos\TinyMceWpf\TinyMceWpf\TinyMceWpf\edit.html"));
}
private void btnGetHtml_Click(object sender, RoutedEventArgs e)
{
string editHtml = this.webBrowser1.InvokeScript("getContent").ToString();
MessageBox.Show(editHtml);
}
}
}
So here how can I suppress the script error message of the web-browser control?
I found many solutions online some that uses SupressScriptErrors property which I did not find in WOF WebBrowser control and the others that used Reflection. I tried many of them.
I tried Wolfie5's Relflection solution at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/4f686de1-8884-4a8d-8ec5-ae4eff8ce6db/[^]. But did not worked for me.
Also I tried another Reflection solution that I explained in greated details here:
http://stackoverflow.com/questions/10030300/script-warning-in-wpf-webbrowser#comment12832540_10030300[^]
I did not get any help on these forums. SO Code Project is my last resort.
Please help. I am stuck here. Thank you.
|
|
|
|
|
I have a asp application that calls a web service sessionservice.asmx. When it tries to make the service call I get the error: error: the remote server returned the error: NotFound. I believe the problem is the wrong endpoint address in the serverreference.clientconfig file. What is the proper endpoint to use when running from the debugger?
|
|
|
|
|
|
I just created a new WPF app. I set up some folder, then added a resource dictionary called AppResources in the Resources folder.
In my window, all I have is
<Window x:Class="MyApp.Views.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2"
Height="400"
Width="400">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources\AppResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
</Grid>
</Window>
The compiler is complaining with
"The file 'Resources\AppResources.xaml' is not part of the project or its 'Build Action' property is not set to 'Resource'."
The file IS part of the project and its Action property IS set to Resource.
I'v been in this project for all of 5 minutes and I can't even get past this.
Anyone know WTF is wrong here??????
Everything makes sense in someone's mind
|
|
|
|
|
That did it.
Thank you
Everything makes sense in someone's mind
|
|
|
|
|
Kevin, you (and the rest of us) are benefiting from some excellent support here, while thanks are appreciated it would be better to upvote the useful answers!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You are right. I will do so from now on.
Everything makes sense in someone's mind
|
|
|
|
|
after adding items to list, still it show "-1" as their index
|
|
|
|
|
Nope. No idea. No code. Throw us a rope here mate; actually give us some code to look at.
|
|
|
|
|
http://www.microsoft.com/design/toolbox[^]
Its very useful site i guess for silverlight startup.I want similar website which could elaborate WPF developments..
I wanna develop some application in wpf..But i am getting confused in many things..
If i could get a simple elaboration by videos then it will be great..
|
|
|
|
|
The basic concepts are the same, do the Silverlight training, this will supply the conceptual framework and allow you to step into WPF.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have binded two simple text strings into a ListBox. works fine. But, I'm having trouble binding a text string and a checkbox to a listbox. The text shows up, but not the checkboxes. I did the code almost the same. It compiles fine. Can anyone tell me why?
List<ExternalAlarmEntry> eaentry = new List<ExternalAlarmEntry>();
CheckBox[] eaCB = new CheckBox[64];
void CreateExternalAlarmTable()
{
ExternalAlarmTable.Height = 120;
for (byte i = 0; i < 5; i++)
{
eaCB[i] = new CheckBox();
eaCB[i].IsChecked = false;
eaentry.Add(new ExternalAlarmEntry()
{
ZoneNum = "Zone " + (i + 1),
ExternalAlarm = eaCB[i]
});
}
ExternalAlarmTable.ItemsSource = eaentry;
}
public class ExternalAlarmEntry
{
public string ZoneNum { get; set; }
public CheckBox ExternalAlarm;
}
|
|
|
|
|
You don't bind UI elements like this. Change the ExternalAlarm property into a boolean (and make it a property, not a field), then use this in your list box ItemTemplate. The ItemTemplate would look something like this:
<DataTemplate x:Key="myItemsTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition />
<Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding ExternalAlarm}" Grid.Column="0" />
<TextBlock Text="{Binding ZoneNum}" Grid.Column="1" />
</Grid>
</DataTemplate> Your list box will look like this
<ListBox ItemTemplate="{StaticResource myItemsTemplate}" x:Name="ExternalAlarmTable" />
|
|
|
|
|
Obviously, I'm not getting it. I've been in the embedded world for 25 years. And, some of the Windows programming isn't making sense quite yet. I guess I'll have to get the exact code working before I can analyze each piece before I understand how it works.
I already have a Grid broken down into subgrids. One of the subgrids, I would like to contain this ListBox. How do I incorporate your WPF code into my subgrid? Here is the previous WPF code in which you said my method isn't going to work.
Also, in my C# code, I will populate the ListBox based on the system the user selects. If he selects system 'A', the box will have 5 entries. If he selects system 'B', the box will have 64 entries. That was the previous code I sent you. I can't do it all in WPF.
<DataGrid Grid.Column="0" Grid.Row="1" Height="150" Width="300"
CanUserAddRows="false"
AutoGenerateColumns ="false"
HorizontalAlignment="Left"
RowHeight ="20"
Margin="15,10,0,0"
VerticalAlignment="Top"
Name="ExternalAlarmTable"
CanUserSortColumns="False"
CanUserResizeColumns="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
SelectionUnit="Cell">
<DataGrid.Columns>
<DataGridTextColumn Header = "Zone #"
Width = "SizeToHeader"
Binding = "{Binding ZoneNum}"
IsReadOnly="true"/>
<DataGridTextColumn Header = "External Alarm Setting"
Binding = "{Binding ExternalAlarm}"
Width="*"/>
</DataGrid.Columns>
</DataGrid>
|
|
|
|
|
OK. I see what you're doing. Right, the problem here is that you are attempting to add a checkbox to a DataGridTextColumn . As I said in my post above, convert ExternalAlarm into a boolean property, and change the DataGridTextColumn into a DataGridCheckBoxColumn .
If you need to implement change notification, so that your display is updated automatically if the ExternalAlarm changes, you'll need to make sure your class implements INotifyPropertyChanged and raise the PropertyChanged event when the value changes in ExternalAlarm .
|
|
|
|
|
Excellent. That's moderately working.
1. How do I position the CheckBoxes at a certain location in the column (like all the way to the left as opposed to in the middle of the column)?
2. If I do the same kind of binding construct for another List of TextMessages and have a class with strings Zone and Text Messages. How do I bind the TextBox to the List? I had that working somewhat and bound the Text Message as a simple string (DataGridTextColumn), but there was no way to restrict the size to 160 characters - like there is with a TextBox. There should be a class DataGridTextBoxColumn, but there is not.
|
|
|
|
|
1. You should be able to set HorizontalAlignment="Left" on the definition of the column.
2. If you need a textbox, all you need to do is put inside DataGridTemplateColumn and put the TextBox inside.
|
|
|
|
|
HorizontalAlignment is not a property that can be used with DataGridCheckBoxColumn.
The TextBox approach with DataGridTemplateColumn worked sortof. Except, it doesn't fill the TextBox with the Binding List until you double click to edit the box. Then, it fills it in properly. How do you get it filled in in prior to entering edit mode?
<DataGrid.Columns>
<DataGridTextColumn
Header = "Zone #"
Width = "SizeToHeader"
Binding = "{Binding ZoneNum}"
IsReadOnly="true"/>
<DataGridTemplateColumn Header="Zone Description Text" Width="*">
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text ="{Binding ZoneDesc}" MaxLength="25"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
for (byte i = 0; i < 64; i++)
{
zdentry.Add(new ZoneDescEntry()
{
ZoneNum = "Zone "+(i+1),
ZoneDesc = GlobalVars.User_Parameters.zonedescrip[i]
});
}
ZoneDescTable.ItemsSource = zdentry;
public class ZoneDescEntry
{
public string ZoneNum { get; set; }
public string ZoneDesc { get; set; }
}
|
|
|
|