c#,wpf,listbox,itemscontrol,selecteditem
I attached a simple example to show button in listbox item when you selected. it should have to bind as RelativeSource and have to use Converter Example: <Window.Resources> <BooleanToVisibilityConverter x:Key="booleanVisibleConverter" /> </Window.Resources> <Grid> <ListBox ItemsSource="{Binding ObservableCollection}" Grid.Row="0" SelectedItem="{Binding Path=Item}" SelectionMode="Single" IsSynchronizedWithCurrentItem="True" Margin="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectedIndex="0">...
Your issue is nothing to do with Animation.The problem is you are comparing sender.Type while you should compare sender itself i.e. use if (sender is TabItem) instead of if (obj is TabItem). Moreover, There is no need to compare sender with TabItem, Lable, Window and etc one by one, they...
c#,wpf,xaml,user-interface,datatemplate
I found an answer that will work for my situation right here: http://stackoverflow.com/a/9687758/4912801 It turns out that setting the Panel.ZIndex property wasn't working because WPF inserts a ContentPresenter element for each item in the ItemsControl. In my application, I was trying to get whatever element the mouse is hovering over...
You can override the default value by setting the property for all buttons in Window.Resources <controls:MetroWindow ... xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Window.Resources> <ResourceDictionary> <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}"> <Setter Property="controls:ButtonHelper.PreserveTextCase"...
I found a way of doing it, with code behind. I put my Expander in a Canvas and I added to my Expander two events: Expanded="searchMenuExpander_Expanded" and Collapsed="searchMenuExpander_Collapsed" which are defined as: private void searchMenuExpander_Expanded(object sender, RoutedEventArgs e) { Canvas.SetZIndex(searchMenuCanvas, 99); } private void searchMenuExpander_Collapsed(object sender, RoutedEventArgs e) { Canvas.SetZIndex(searchMenuCanvas,...
Because the class that translates the metadata to a actual method is called Binder and BindingFlags are flags that are passed on to the binder to connect to the method.
Since The View-Model is an abstraction of the view that exposes public properties and commands, it doesn't make a lot of sense for a view to have two view-models the way you explained. It'll be more rational if there is a VM class as the view-model of your view that...
c#,xml,wpf,visual-studio,relative-path
First, ensure that the file is definitely copied into your output ./bin/ directory on compile: This worked perfectly for me in my WPF application: const string imagePath = @"pack://application:,,,/Test.txt"; StreamResourceInfo imageInfo = Application.GetResourceStream(new Uri(imagePath)); byte[] imageBytes = ReadFully(imageInfo.Stream); If you want to read it as binary (e.g. read an image...
These Styles reference other Styles and Templates via StaticResource: MyFocusVisualStyte (Typo? Shouldn't it be MyFocusVisualStyle?), SliderThumbStyle, SliderRepeatButtonStyle, HorizontalSlider, VerticalSlider... All these Styles and Templates must exist and be defined BEFORE they're used. In this case, the resources must be defined in this order (I'll copy only the first node of...
You can accomplish something like this with DataTamplates: <Window x:Class="StackSimpleSample.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> <Grid.Resources> <Style x:Key="RedStyle" TargetType="TextBlock"> <Setter Property="Foreground" Value="Red"/> </Style> <Style x:Key="GreenStyle" TargetType="TextBlock"> <Setter Property="Foreground"...
As usual the answer is ain't common, it depends on how you really want to implement it. But for the sake of patterns and organized code, i would recommend that you have: Separate Viewmodel per view: each viewmodel should only contain as many data as many you want to display/work...
To modify the color of the caret (which assume is what you call "positionmarker") you have to set the CaretBrush property of the TextBox.
c#,wpf,mvvm,data-binding,user-controls
This is a common misconception. When a DependencyProperty's value changes, the code in its CLR property's set is not executed. You need to use a PropertyChanged callback if you want to execute some code whenever the property value changes. Your UserControl code should look like this, instead: public static readonly...
if you want to use same Click handler for two button, try this: private void btnDashboard_Click(object sender, RoutedEventArgs e) { Button btnSender = sender as Button; if(btnSender.Name == "btn1") { //Code for Button1 } else { //Code for Button2 } } Also make sure each button has a Name property...
The AncestorType should be MainWindow not MainViewModel. MainViewModel is not a class that is part of the visual tree.
just hold the color values in a config file simple text file will suffice. though you can use VisualStudio Resource file.. file will contain lines in each: item_enum_name item_type item_value for example: main_screen_bg_color Color Black company_logo URI \logos\logo1.jpg and so on.. just load the file parse it and use bind...
{Binding dtone} tries to bind to dtone property of DataContext, which is MainWindow. There is no dtone property in MainWindow class, only a private field, and you cannot bind to fields. Possible solutions: make dtone a property or change DataContext = this to DataContext = dtone and {Binding dtone} to...
I think you're confusing stuff. I assume you want your State items to have a string Measure property, and not a collection of them, but you want to be able to select the Measure value from a Combo with several options... If that's the case, then you should redefine your...
This adds a picture to the background of your radio button. myRadioButton.Content = new Image() { Source = (new ImageSourceConverter()).ConvertFrom( "Images/pic.png") as ImageSource }; ...
The UI thread in WPF uses the Dispatcher to schedule and process all updating of the UI. The dispatcher basically maintains a queue of tasks to run on the thread. If you are monopolizing the thread, the queue will just back up until you give it a chance to run...
But you aren't binding a list of strings to a ListView, you are binding an IEnumerable<String> to a TextBlock.Text field, when it is expecting a String as you can see in the errors. The fastest way to solve your problem is to change the line to this.AInfoLv.Items.Add(new { Label=" "...
I'm going to attempt to answer your questions directly, however there is much that can be discussed here. What this template doing? All controls have some kind of default template, a pre-defined look and feel of what the control looks like. The Template is overriding the default look and feel...
wpf,storyboard,wpf-controls,routed-events
You may use a DoubleAnimation instead of an ObjectAnimationUsingKeyFrames. By only setting its To property, but not From, the animation starts from the current property value. It requires that you also set an initial value of the Height of the Border: <Border Height="20" ...> <Border.Triggers> <EventTrigger RoutedEvent="MouseLeftButtonUp"> <BeginStoryboard> <Storyboard> <DoubleAnimation...
c#,wpf,multithreading,listbox,backgroundworker
@Clemens answer from his comment on the original question provided the solution. Ensuring that the file stream was being closed responsibly and changing the BitmapCacheOption to OnLoad now shows each image in the asynchronous load. The final code for the asynchronous load looks like: private void LoadAsync(object sender, DoWorkEventArgs e)...
c#,wpf,image,background,resources
Firstly, add a Folder to your Solution (Right click -> Add -> Folder), name it something like "Resources" or something useful. Then, simply add your desired image to the folder (Right click on folder -> Add -> Existing item). Once it's been added, if you click on the image and...
c#,wpf,itemscontrol,contentpresenter
I found an easier way to solve this problem by using horizontal listbox. Thanks for responses
You can implement your OptionalPhoneAttribute based on the original PhoneAttribute: public sealed class OptionalPhoneAttribute : ValidationAttribute { public override bool IsValid(object value) { var phone = new PhoneAttribute(); //return true when the value is null or empty //return original IsValid value only when value is not null or empty return...
That is not the correct way to register a dependency property. public bool UseCustomTooltips { get { return (bool)GetValue(UseCustomTooltipsProperty); } set { SetValue(UseCustomTooltipsProperty, value); } } public static readonly DependencyProperty UseCustomTooltipsProperty = DependencyProperty.Register("UseCustomTooltips", typeof(bool), typeof(MyControl), new PropertyMetadata(false, new PropertyChangedCallback(MyCallbackMethod))); Use the propdp snippet, it really is a beautiful thing....
What you can do is create the StackPanel in the xaml markup itself with the Visibility set to Collapsed and just toggle the visibility of the StackPanel on the check event of CheckBox
Instead of a static counter you should have a view model with a collection of Person objects public class ViewModel { public ObservableCollection<Person> Persons { get; set; } } and bind the ItemsSource property of the ListView to this collection. <ListView ItemsSource="{Binding Persons}"> ... </ListView> You could now bind to...
To have such a result, your grid must be really small. I see at least 3 solutions to your issue: 1- Make your grid a bit bigger until it fits. 2- Put 2 columns in your grid, you'd put the number on the left column and the % on the...
wpf,xaml,rotation,rendertransform
The problem is that the Transforms were applied after the layout pass. You should use a LayoutTransform to perform the transformation before the layout is calculated: <Image Name="ImageTarget" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Uniform" RenderTransformOrigin=".5,.5"> <Image.LayoutTransform> <TransformGroup> <ScaleTransform ScaleX="{Binding Main.BindedViewMode, Converter={StaticResource ImageSizeConverter}}" /> <ScaleTransform ScaleY="{Binding Main.BindedViewMode,...
I suspect the issue has to do with how xaml resources work. Since you are creating a ToolTip instance inside of a style setter, you are likely only ever creating one ToolTip and assigning it to every GridSplitter that uses that style. You could try adding x:Shared="false" to your style...
wpf,datatemplate,datatrigger,2-way-object-databinding
Your answer can be found in the Dependency Property Value Precedence page on MSDN. In short, you have set a local value on the IsOpen property and that has a higher precedence than the value set by the Trigger. The solution is to not set the local value, but to...
c#,wpf,xaml,binding,commandparameter
<Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mine="clr-namespace:WpfApplication2" Title="MainWindow" Height="350" Width="525"> <Grid> <mine:SquareControl Coordinates="{Binding VMCoordinates, Mode=TwoWay}"/> </Grid> </Window> In this case the namespace 'mine' is the namespace of your app. So in the main window the line inside the grid says "Place an instance of SquareControl in my view...
c#,wpf,validation,data-binding,radio-button
In my opinion you have 2 solutions: the first one - the easiest one - is to set a default for Gender property. In this way one among the two radiobuttons will be check and the "required" attribute will be always satisfied. The second solution is to "mask" a ListView...
At the end of the opening Window tag, the tutorial's code imports the namespace your are talking about. Do you have the following XAML in your opening Window tag? xmlns:chartingToolkit= "clr-namespace:System.Windows.Controls.DataVisualization.Charting; assembly=System.Windows.Controls.DataVisualization.Toolkit" If you are unfamiliar with referencing CLR namespaces from XAML, I strongly recommend reading this MSDN introduction on...
You can't access DataGridCell.Content that way, use a DataTrigger instead based on your DataGrid.SelectedItem.YourProperty like this: <DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="FontWeight" Value="Bold" /> <Style.Triggers> <DataTrigger Binding="{Binding YourProperty}" Value="0"> <Setter Property="FontWeight" Value="Normal"/> </DataTrigger> </Style.Triggers> </Style> </DataGrid.CellStyle> EDIT: Assuming your DataGridColumns are text-based then you can...
You can utilize the utilize the PrintDocument class, which is not WPF specific. This class allows you to send output to a printer. The PrintPage event should be handled, where you utilize the PrintPageEventArgs to obtain a Graphics context; which is used to draw the exam to the printer output....
As @goobering already mentioned, this is a very broad set of questions, I will attempt to guide you in the right direction here. How can I parse data from pages? I would recommend starting with RSS. Practically all news websites have some kind of RSS feed that you can tap...
Since you're marking the event as Handled (e.Handled = true), you're effectively preventing the DataGrid from sorting and the SortDirection is never changing. You'll have to manage the sort direction yourself. But it should be as easy as this: private ListSortDirection lastSortDirection; private string lastSortMemberPath; public async void Sorting(DataGridSortingEventArgs e)...
client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate"); With this you tell the server that you allow it to compress the response gzip/deflate. So the response is actually compressed which explains why you get the kind of response text you get. If you want plain text, you shouldn’t add the header, so the server won’t...
c#,wpf,linq,linq-to-sql,sql-order-by
Given your example data where the first number is always a single digit: allScenes.OrderBy(x => x.SceneNumber).ToList() If you can possibly have multi-digit numbers, please provide them and where you want them in the sort order. This is one way to sort multiple digit numbers: var allScenes = new[]{ new {SceneNumber="4B"},...
c#,wpf,multithreading,entity-framework,sqlce
After some more testing it appears that I shouldn't be using the await keyword in he call to the async method. Executing the call like this: Task.Run(() => PerformContextSubmitAsync()); Doesn't block the original calling thread, but it doesn't seem to actually execute in an asynchronous fashion. It seem to behave...
It seems to me that your main application namespace is TreeViewTestC and not MyNameSpace. Therefore, you may well need to tell the compiler that your MyNameSpace is actually in the TreeViewTestC assembly, despite you only having a single project. Try using this instead: xmlns:MyTree="clr-namespace:MyNameSpace;assembly=TreeViewTestC" ...
You can use a Popup control, coupled with it's Placement property to display your popup based on the current location of your buttons. <Popup Placement="Top" PlacementTarget="{Binding ElementName=yourButton}" ... /> Inside your Popup, you can place your UserControl or any content element which will act as the popup's content. See here...
c#,wpf,bytearray,converter,inkcanvas
My problem was that I didn't serialize the output to the saved file and thus the when I loaded that file deserializing it tripped an error. Here is the correct code: private void SaveByteArrayToFile(byte[] byteArray) { var dialog = new System.Windows.Forms.FolderBrowserDialog(); string filepath = ""; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {...
StackPanel has a property called as "FlowDirection". Is this what you are looking for? <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="Yellow" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,2,0" Name="MainButtonsPanel" Width="400" FlowDirection="RightToLeft"> ...
Try using a DataTrigger with predefined DataTemplate items: <DataTemplate x:Key="OneItem" DataType="{x:Type ValueItem}" > <TextBox Text="{TemplateBinding Id}" /> </DataTemplate> <DataTemplate x:Key="MultiItems" DataType="{x:Type ValueItem}" > <ComboBox ItemsSource="{TemplateBinding ValueItems}" DisplayMemberPath="ValueName" SelectedValuePath="ID" SelectedValue="{TemplateBinding Id}" /> </DataTemplate> And then use a Content control to place the style accordingly. I haven't tried this but your data...
The binding in the ListBox ItemTemplate should be to the ImageViewModel's ImageBinary property, instead of Images: <DataTemplate> <Border ...> <Image Source="{Binding ImageBinary}" .../> </Border> </DataTemplate> ...
c#,wpf,xaml,datagrid,custom-controls
I had to remove the section from the Generic.xaml style for the DataGrid to properly layout and created the column in code. protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); CloneColumn.Visibility = ShowCloneColumn ? Visibility.Visible : Visibility.Hidden; } private DataGridTemplateColumn _cloneColumn; private DataGridTemplateColumn CloneColumn { get { if (_cloneColumn == null)...
If you can do this line by line then the answer is simple read a line process the line write the line If you want it to go a bit faster then put those in three BlockingCollections with a specified upper bound of like 10 so a slower step is...
wpf,xaml,binding,windows-phone-8.1
The problem is the use of DataContext. Your MainPage has a DataContext : DataContext="{Binding Main, Source={StaticResource Locator}}" LoadingView also has a DataContext So, when you write this code : You try to find Test2 as a field in the DataContext of the LoadingView because you're in the same View. To...
The solution was the easiest in the world. I need to use the NewsFeedPanel as ItemsPanel instead of a wrapPanel. Thanks Clemens for the suggestion.
You're not actually utilising the BorderBrush and BorderThickness properties... you need to actually do something with them from inside your ControlTemplate. Try this: <ControlTemplate TargetType="{x:Type Button}"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> ...
.net,wpf,xaml,mvvm,data-binding
On your UserControl's code-behind (FilterTraceDataControl.xaml.cs), add a DependencyProperty, like this: public string Text { get { return (string)this.GetValue(TextProperty); } set { this.SetValue(TextProperty, value); } } public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string), typeof(FilterTraceDataControl),new PropertyMetadata(null)); Then bind your UserControl's TextBox to it by RelativeSource or ElementName: <TextBox x:Name="PartNumbTextBox" Width="120"...
wpf,mvvm,code-behind,datacontext
Validation.Error is an event, not a property. You can't set Bindings to events. You can use things like MVVM Light's EventToCommand, or Microsoft's own Interactivity EventTrigger to associate Commands to Events. But there really isn't anything wrong with just adding a regular event handler in code-behind and calling some viewmodel...
If you see the Tag is setting for the combo box itself and not for its individual item. You can build a dictionary and use it as datasource of your combo box. Specify the value and display members of the combo box with dictionary key and value attributes Try modifying...
You can simply have a private variable outside of the Button_Click1 method which will hold the chosen file names. string[] files; private void Button_Click1(object sender, RoutedEventArgs e) //BROWSE BUTTON { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Multiselect = true; dlg.FileName = "Document"; dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable<bool>...
Here is the solution that works: private void tabControlOrganizer_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (tabControlOrganizer.SelectedItem != null) { if (e.Source is TabControl) { if (tabItemTrades.IsSelected) { dataGridTrades.ItemsSource = Queries.GetTradeList(dataContext); } SelectionChanged was the problem: In C# WPF, why is my TabControl's SelectionChanged event firing too often? In free time I...
The problem is with your ContentStringFormat Change the ContentStringFormat to Like this <Label Name="lblSliderSpeed" Content="{Binding ElementName=speedSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" ContentStringFormat="{}{0:00}"/> And No code Required In page Behind. Because,The "#" custom format specifier serves as a digit-placeholder symbol. If the value that is being formatted has a digit in...
StackPanel stretches accordingly to the size of its content. So if you use Grid and with TextWrapping you can achieve the desired result <Grid> <TextBlock TextWrapping="Wrap" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus leo lectus, viverra ut lobortis vel, mollis eget lectus. Suspendisse laoreet consequat ultrices. Curabitur ultricies,...
You could use the always handy FindChild<T> function to retrieve the ScrollContentPresenter inside the ListView, and use your zooming function with it. public Control() { InitializeComponent(); this.Loaded += new RoutedEventHandler(Control_Loaded); } private void Control_Loaded(object sender, RoutedEventArgs e) { var presenter = FindChild<ScrollContentPresenter>(listView, null); var mouseWheelZoom = new MouseWheelZoom(presenter); PreviewMouseWheel +=...
In WPF, you can't even draw something in pixel units without at least some extra effort. WPF uses "device independent units" where each unit is 1/96th of an inch. Even that is only a theoretical relationship, as it depends on the display device correctly reporting its resolution, which in turn...
It turned out that the solution is easier than I expected. Here is the solution in case if enybody needs it. I just had to modify the RegionPopupBehaviours to use AllActiveregion instead of the original SingleActiveRegion and in the DialogActivation I had to remove the first call to the CloseContentDialog....
Your resources are available in the code behind through the Resources property, which is the merged dictionary of resources. Your item will be available through the key that you've given it. Assuming that your example code for setting the FullName property is in your Window code behind, the following code...
The very first line in the remarks section of the documentation for the CollectionView class says: You should not create objects of this class in your code. So, I am guessing it is probably not designed to be used the way you are using it. I always use CollectionViewSource.GetDefaultView(collection) (which...
In order to observe changes in a collection WPF provides the ObservableCollection class which implements INotifyCollectionChanged and INotifyPropertyChanged. Replace List<T> with ObservableCollection<T> and your code should work.
I have been trying another solution for your problem. <Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=., RelativeSource={RelativeSource Self}, Converter={StaticResource DataGridCellToBooleanConverter}, ConverterParameter=IsEnabled}" Value="True"> <Setter Property="Background" Value="Yellow"/> </DataTrigger> </Style.Triggers> </Style> <DataGrid CellStyle="{StaticResource DataGridCellStyle}">...
c#,wpf,inotifypropertychanged,getter-setter
Yes, it will. You're still going to be a little sick of writing private backing fields and repetitive parts though: private int _foo; public int Foo { get{return _foo;}, set { SetProperty("Foo", ref _foo, value); } } you can't easily escape from that. INPC works based solely on three things:...
You can add xml:space="preserve" to your resource. This will, like it says, preserve the space. <System:String xml:space="preserve" x:Key="NumStartsTotal">Total: </System:String> More info here and here....
WPF's ItemsControl is the correct way to show items in your views when the number of items can change. Many controls inherit from ItemsControl, like the ComboBox itself, or the DataGrid, or the ListBox... But in this example I'll use ItemsControl directly, since what you're trying to do doesn't need...
Set the WindowState property instead of Width and Height: mainWindow.WindowState = WindowState.Maximized; ...
manually do the add, update, and delete myself Please don't delete yourself. ;-) Xml node processing is a complex process and does not easily lend itself to such a scenario as adding and deleting from a string list which is what the question is patterning itself off of.... At...
Here is a way of doing it only in XAML: <Window x:Class="RadioButtonAndPopup.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> <StackPanel> <StackPanel.Resources> <Style TargetType="{x:Type RadioButton}"> <EventSetter Event="Click" Handler="EventSetter_OnHandler"/> </Style> </StackPanel.Resource> <RadioButton x:Name="RadioBtn"...
One minor mistake made by you in CustonDatagrid.xaml <DataGrid ItemsSource="{Binding ElementName=CustonDataGrid, Path=Colection}" DockPanel.Dock="Top"></DataGrid> There is no element called CustonDataGrid because of which the elements were never reflected. Changed it to <DataGrid ItemsSource="{Binding Path=Colection}"></DataGrid> I also made minor change in your MainWindow.cs public partial class MainWindow : Window { public MainWindow()...
c#,wpf,background-process,caliburn.micro
To start a background task you can use Task.Run method. And to execute a code in the main thread you can use Dispatcher of the page (in case of VM context I have placed call of Application.Current.Dispatcher) public class MainViewModel: Screen { public MainViewModel() { Task.Run(() => { while (!ConnectServer())...
c#,wpf,binding,imagesource,imagebrush
If you are trying to localize your application, you should consider looking into existing libraries to help you out, such as WPFLocalizationExtension. To answer your immediate question, you could define all of your images as either static properties or as resources somewhere in your application, and assign them to the...
System.Windows.Interactivity.dll is not in the GAC, so .Net doesn't know where to find it. By adding a reference to your main project, you make the build system copy the DLL to the output folder. This lets the runtime find it....
wpf,xaml,data-binding,wpf-controls
Your 'null' item should simply be an item in your collection (of the same type as the rest of the items) that has no properties set, or at least no properties that are displayed. That way, you can avoid the Binding errors all together, because your 'null' item will have...
wpf,sorting,listbox,compare,collectionview
You just have to check if it starts with "price". Note that I don't think that ToString() is appropriate; you should rather implement IComparer<T> and strongly type your objects in your listbox. public int Compare(object x, object y) { // test for equality if (x.ToString() == y.ToString()) { return 0;...
If you don't want any input or hit testing on a certain element you should set the IsHitTestVisible property to false: <Grid> <Canvas Name="Canvas" Background="#EFECCA"> <DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="{Binding ActualWidth, ElementName=Canvas}" Height="{Binding ActualHeight, ElementName=Canvas}" MouseLeftButtonDown="DockPanel_MouseLeftButtonDown" TouchDown="DockPanel_TouchDown" Panel.ZIndex="2" Background="Transparent"> </DockPanel> <Button Width="50" Height="50"...
Found the solution. Removed MetroDark.MSControls.Toolkit.Implicit.xaml which was not needed and also deleted the Reference to the WPFToolkit Dll....
Color is a structure, which means it is passed by value, not by reference. You are basically making copies of the colors, modifying those copies, and then letting them go out of scope and get deleted. You should put the colors into the resource dictionary by doing something along the...
After a long time I finally figured out what the real problem was - my Antivirus program Avast! was running the app in a sandbox mode (normally it notifies when running program in a sandbox mode, however not with this one), and once it finished testing the program (after approximately...
.net,wpf,dll,microsoft-band,.net-core
The current Band SDK does not support Windows desktop (i.e. Win32) applications. It supports only Windows Store and Windows Phone (i.e. WinRT) applications. Portable libraries can be confusing as the terms '.NETCore' and 'netcore451' refer to the Windows Store version of the .NET framework....
You could prevent this with some handling of the SelectionChanged and TextChanged events. <TextBox Text="{Binding Messages, Converter={StaticResource ListToStringConverter}}" HorizontalAlignment="Center" SelectionChanged="TextBox_SelectionChanged" TextChanged="TextBox_TextChanged" /> Then, in the handlers: private int selectionStart; private int selectionLength; private void TextBox_SelectionChanged(object sender, RoutedEventArgs e) { var textBox = sender as TextBox; selectionStart = textBox.SelectionStart; selectionLength =...
Finally, I got the answer from https://github.com/cefsharp/CefSharp/issues/1080#issuecomment-111969127 I am sorry post the duplicate thread online. With the amaitland's help. I resolved this issue. We just needed remove OnMouseLeftButtonDown method. Thanks for your time....
I managed to get it working using an IMultiValueConverter like this: public class BorderCollectionConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var borderCollection = new BorderCollection(); borderCollection.AddRange(values.OfType<Border>()); return borderCollection; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new...
Accessing your view components from inside your viewmodel is not the way to do things in MVVM. Because it is specifically not designed to work this way, you will have to go out of your way to make it work. You should probably investigate how to accomplish your goals using...
You're trying to deserialize it into a list of RootObject but in reality the JSON is just a single root object. Try RootObject obj = JsonConvert.DeserializeObject<RootObject>(responseText); instead. And then of course you need to change your for loop because obj is no longer a List<>. If you want to iterate...
c#,wpf,xaml,listview,windows-runtime
If you have to use ListView then this is how it works: <ListView Margin="120,30,0,120" ItemsSource="{Binding MainViewModel}" Grid.Row="1"> <ListView.View> <GridView> <GridViewColumn DisplayMemberBinding="{Binding Data, Mode=TwoWay}" Width="100" Header="Column 1" /> <GridViewColumn DisplayMemberBinding="{Binding Year, Mode=TwoWay}" Width="100" Header="Column 2" /> <GridViewColumn DisplayMemberBinding="{Binding Month, Mode=TwoWay}" Width="100" Header="Column 3" /> <GridViewColumn...
Here is a variation of your code, the points to note are: Model: refactored to be more object oriented and closer to real world situations, it is now a parent-child relationship between objects View Model: now implements INotifyPropertyChanged to notify framework elements about changes causing then to update its binding...