|
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.
|
|
|
|
|
Well, I don't know why this works (yet), but this was the answer.
0) Create a modal window.
1) Add a delegate for the Render method to the window
2) Add a method to call in the window, like this:
public void SetSlide(UserControl slide,
RenderDelegate renderMethod,
DateTime fiscalDate,
VMSlideItem slideItem)
{
this.gridMain.Children.Clear();
this.gridMain.Children.Add(slide);
renderMethod(fiscalDate, slideItem);
slide.Measure(new Size(1024d,768d));
slide.Arrange(new Rect(0,0,1024,768));
slide.UpdateLayout();
}
The key was calling the slide's render method from within the window (and yes, I still had to call Measure , Arrange and UpdateLayout ).
".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 13:30pm.
|
|
|
|
|
I have a simple UserControl that has one dependency property:
public partial class MyUserControl : UserControl
{
public MyUserControl()
{
InitializeComponent();
}
public double LocationX
{
get { return (double)GetValue(LocationXProperty); }
set { SetValue(LocationXProperty, value); }
}
public static readonly DependencyProperty LocationXProperty =
DependencyProperty.Register("LocationX", typeof(double), typeof(MyUserControl), new PropertyMetadata(0d));
}
The user control just has a single rectangle in it, and I want to bind it to the ItemsControl:
<ItemsControl x:Name="myCanvas">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.Left" Value="{Binding LocationX}"/>
<Setter Property="Canvas.Bottom" Value="0"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
Its binded to an ObservableCollection:
public partial class MainWindow : Window
{
ObservableCollection<MyUserControl> myData = new ObservableCollection<MyUserControl>();
public MainWindow()
{
InitializeComponent();
myData.Add(new MyUserControl() { LocationX = 50 });
myData.Add(new MyUserControl() { LocationX = 350 });
myCanvas.ItemsSource = myData;
}
}
The Canvas.Bottom is set according to the value given, but the value I want to be binded won't work correctly. What Am I doing wrong here?
|
|
|
|
|
Damn, answering my own question, again:
Well, all I need to do is to set the x:Name="MyControl" in the user control, and in the binding set ElementName=MyControl, Path="LocationX"
|
|
|
|
|
A much better approach would be,
<... Value="{Binding Path=LocationX, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"/>
"As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"
|
|
|
|
|
Yeah, I did try that too, and it worked fine for my other controls when the Dependency Property was within the Control that I wanted to bind to. Btw, you don't need the x:Type to make it work:
Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=XLabel}"
But as soon as I had a collection of different user controls and I wanted to access them, I had to say ElementName for some reason. I guess it was because it couldn't find the correct property in the first Ancestor type.
|
|
|
|
|
Why would this be a better approach?
This space for rent
|
|
|
|
|
You might set the name of the user control to something different when its an element in your window. Setting the name property in the user control will still work though since it is initialized before the containing window. Using Binding.RelativeSource is a suitable option.
"As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"
|
|
|
|
|
I ended up by setting the x:Name and specify the ElementName as I said, but I would really like to know how to implement the RealativSource in my project.
A simple WPF LineChart control[^]
I couldn't see exactly how to do it.
|
|
|
|
|
My answer was in response to Pete's question.
"As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"
|
|
|
|
|
Ah, posted it in the wrong place. I couldn't make it work properly. It simply wouldn't find the x:Type UserControl. It refused to bind, and I don't know how to fix it.
|
|
|
|
|
Hi,
I have a Datagrid, it is bound with an ObsevableCollection of ClassA which has two Properties Id, Name.
Up to here Datagrid works fine, now I want the selected row's Id value of Datagrid to be populated in the ViewModel.
Eventually this should be passed to another View where it will be used.
Can anybody please help me in achieving this, it is very urgent? Any help is appreciated, may be a link, a code snippet or even a suggestion helps me greatly.
Thaanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
In your ViewModel, expose a SelectedItem property (of the same type as the entries in your ObservableCollection ). Bind the SelectedItem property from your grid to this property in the ViewModel. When the selection changes in the grid, the underlying selection changes in the VM.
This space for rent
|
|
|
|
|
Hi All,
I have a WPF application named : TestWPFApplication, In that I have folders View and View Model. I have View class as below
namespace TestWPFApplication
{
public partial class MainWindow : Window
{
TestViewModel _testViewModel;
public MainWindow()
{
InitializeComponent();
_testViewModel = new TestViewModel();
DataContext = _testViewModel;
}
}
}
then I have ViewModel class as below.
namespace TestWPFApplication
{
public class TestViewModel : INotifyPropertyChanged
{
TestData _testData;
public TestSpecificCommand TestSpecificCommand { get; set; }
public TestViewModel()
{
_testData = new TestData();
_personNames = new ObservableCollection<TestData>();
this.TestSpecificCommand = new TestSpecificCommand(this);
}
private string _name;
public string Name
{
get { return _name; }
set
{
_name = value; NotifyPropertyChanged("Name");
}
}
private int _id;
public int Id
{
get { return _id; }
set
{
_id = value; NotifyPropertyChanged("Id");
}
}
}}
When I am trying to reference this ViewModel as static resource to bind properties of ViewModel to View then its giving error as below.
<Window x:Class="TestWPFApplication.MainWindow"
xmlns:testns="clr-namespace:TestWPFApplication;assembly=TestWPFApplication"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
>
<Window.Resources>
<testns:TestViewModel x:Key="_testViewModel" Name="Abdul">
</testns:TestViewModel>
</Window.Resources>
<Grid>
<Label Content="Enter Name" HorizontalAlignment="Left" Margin="58,62,0,0" VerticalAlignment="Top" Name="lblName"/>
<TextBox Text="{Binding Name, Mode=OneWay, Source={StaticResource _testViewModel}}" HorizontalAlignment="Left" Height="22" Margin="160,64,0,0" TextWrapping="Wrap"
Name="txtName" VerticalAlignment="Top" Width="120"/>
<Label Content="Enter Id" HorizontalAlignment="Left" Margin="58,17,0,0" VerticalAlignment="Top" Name="lblId"/>
<TextBox Text="{Binding Name, Mode=OneWay, Source={StaticResource _testViewModel}}" HorizontalAlignment="Left" Height="22" Margin="160,18,0,0" TextWrapping="Wrap"
Name="txtId" VerticalAlignment="Top" Width="120"/>
<!--<Button Content="Save" HorizontalAlignment="Left" Margin="277,142,0,0" VerticalAlignment="Top" Width="74" Name="btnSaveSpecific"
Command="{Binding Path=TestSpecificCommand}"
CommandParameter="{Binding ElementName=txtName, Path=Text}" />-->
<Button Content="Save" HorizontalAlignment="Left" Margin="277,142,0,0" VerticalAlignment="Top" Width="74" Name="btnSaveSpecific"
Command="{Binding Path=ClickCommand}"
/>
<DataGrid HorizontalAlignment="Left" Margin="103,188,0,0" VerticalAlignment="Top" Height="98" Width="313"
IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=PersonNames, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Name of Employee" Binding="{Binding Path=Name}" />
</DataGrid.Columns>
</DataGrid>
<pre>
</Grid>
And error is as below
Error 1 The tag 'TestViewModel' does not exist in XML namespace 'clr-namespace:TestWPFApplication;assembly=TestWPFApplication'. Line 8 Position 10. \\VBOXSVR\VMShared\Test Projects\TestWPFApplication\TestWPFApplication\View\MainWindow.xaml 8 10 TestWPFApplication
Error 2 The name "TestViewModel" does not exist in the namespace "clr-namespace:TestWPFApplication;assembly=TestWPFApplication". \\VBOXSVR\VMShared\Test Projects\TestWPFApplication\TestWPFApplication\View\MainWindow.xaml 8 9 TestWPFApplication
Error 3 The type 'testns:TestViewModel' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. \\VBOXSVR\VMShared\Test Projects\TestWPFApplication\TestWPFApplication\View\MainWindow.xaml 8 10 TestWPFApplication
<pre>
Any help please? I am not able to understand this, I have ViewModel in the same assembly as View and then I try to reference them using the same Assembly name and Name space name it says the ViewModel class is not available.
Any help is appreciated please help me.
<div class="signature">Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."</div>
|
|
|
|
|
It looks like your view and view-model are in the same assembly. Try removing the assembly from the XML namespace declaration:
<Window x:Class="TestWPFApplication.MainWindow"
xmlns:testns="clr-namespace:TestWPFApplication"
...
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Rick,
I have removed it as below, it is compiling and running executing, but showing me that Invalid Markup on the UI screen, when I try to open the Properties settings, the Properties box is not showing me any Properties, why could that be?
Thank you very much my friend.
<Window x:Class="TestWPFApplication.MainWindow"<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:testns="clr-namespace:TestWPFApplication"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
>
<Window.Resources><br />
<testns:TestViewModel x:Key="_testViewModel" Name="Abdul">
</testns:TestViewModel>
</Window.Resources>
<Grid>
<Label Content="Enter Name" HorizontalAlignment="Left" Margin="58,62,0,0" VerticalAlignment="Top" Name="lblName"/>
<TextBox Text="{Binding Name, Mode=OneWay}" HorizontalAlignment="Left" Height="22" Margin="160,64,0,0" TextWrapping="Wrap"
Name="txtName" VerticalAlignment="Top" Width="120"/>
<pre>
<Button Content="Save" HorizontalAlignment="Left" Margin="277,142,0,0" VerticalAlignment="Top" Width="74" Name="btnSaveSpecific"
Command="{Binding Path=TestSpecificCommand}"
CommandParameter="{Binding ElementName=txtName, Path=Text}" />
<Label Content="Enter Id" HorizontalAlignment="Left" Margin="58,17,0,0" VerticalAlignment="Top" Name="lblId"/>
<TextBox Text="{Binding Name, Mode=OneWay}" HorizontalAlignment="Left" Height="22" Margin="160,18,0,0" TextWrapping="Wrap"
Name="txtId" VerticalAlignment="Top" Width="120"/>
<Button Content="Save 2" HorizontalAlignment="Left" Margin="412,142,0,0" VerticalAlignment="Top" Width="74" Name="btnSaveSpecific2"
Command="{Binding Path=ClickCommand}"
/>
<DataGrid HorizontalAlignment="Left" Margin="103,188,0,0" VerticalAlignment="Top" Height="98" Width="313"
IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=PersonNames, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Name of Employee" Binding="{Binding Path=Name}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 16-May-16 12:34pm.
|
|
|
|
|
indian143 wrote: Hi Pete,
I am not Pete.
indian143 wrote: Invalid Markup on the UI screen
Does it give you an error message? Maybe something in the "Error List" or "Output" windows?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry and thank you for bringing it up, good catch
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Hi Rick,
It says that the
The name "TestViewModel" does not exist in the namespace "clr-namespace:TestWPFApplication.ViewModel". \VBOXSVR\VMShared\Test Projects\TestWPFApplication\TestWPFApplication\View\MainWindow.xaml 9 9 TestWPFApplication
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
But according to the code you posted earlier, it's not in the TestWPFApplication.ViewModel namespace; it's in the TestWPFApplication namespace.
It sounds like you've put:
xmlns:testns="clr-namespace:TestWPFApplication.ViewModel"
instead of:
xmlns:testns="clr-namespace:TestWPFApplication"
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Friends,
I have two Textboxes, One for Id and another for the Name, I need to pass both of these two into MyViewModel class Id and Name Properties in a Button Click, so far I am able to pass one of them to the ViewModel, how can I pass both the parameters to the ViewModel, any help is greatly helpful. Thanks in advance please.
So far I am able to do as below
in View
<Button Content="Save" HorizontalAlignment="Left" Margin="277,142,0,0" VerticalAlignment="Top" Width="74" Name="btnSaveSpecific"
Command="{Binding Path=TestSpecificCommand}"
CommandParameter="{Binding ElementName=txtName, Path=Text}" />
In the Command class
public void Execute(object parameter)
{
var values = (string)parameter;
this.ViewModel.AddAnItem(values);
}
In View Model
public void AddAnItem(string _name)
{
int t;
if ((_personNames == null) || (_personNames.Count() <= 0))
t = 1;
else
t = (_personNames.Count <= 0) ? 1 : _personNames.Max(x => x.Id) + 1;
_personNames.Add(new TestData(t, _name));
}
I want to change this AddAnItem to take two parameters int and string and if possible return value also, but return is not important, what is important is to take two parameters. Please need help, any sort of help a link or code snippet or even a suggestion also helps.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 15-May-16 7:38am.
|
|
|
|
|